1
1

Okay, here is the massive checkin that restructures the registry trigger system for scalability. Actually, it isn't "quite" as large as it looks - it just touches a bunch of files.

Also included is a fix to the attribute problem for singletons.

Short explanation:
The prior system placed triggers and subscriptions on the registry for each process - approximately eight/process. Each of these had to be checked every time there was a registry operation such as a "put" or "increment-value". For large numbers of processes, this repetitive checking consumed some significant time.

The new system allows processes to "attach" to existing triggers and subscriptions, without creating a new one. Thus, there are now only eight triggers and five subscriptions on a job - *regardless of how many processes are being run*. This means that the registry now takes the same amount of time (which is pretty darn short) to process an operation regardless of how many processes are in a job.

I'll provide some startup times from scalability tests shortly - need to complete the commit so I can move the system to an appropriate cluster.

This commit was SVN r6164.
Этот коммит содержится в:
Ralph Castain 2005-06-24 16:59:37 +00:00
родитель 35375f0653
Коммит 8271d3f30e
76 изменённых файлов: 4666 добавлений и 3496 удалений

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

@ -26,6 +26,7 @@
#include "mca/ns/ns.h" #include "mca/ns/ns.h"
#include "mca/gpr/gpr.h" #include "mca/gpr/gpr.h"
#include "mca/errmgr/errmgr.h" #include "mca/errmgr/errmgr.h"
#include "mca/schema/schema.h"
/* /*
@ -65,37 +66,71 @@ static int attr_impi_host_color = 0;
int ompi_attr_create_predefined(void) int ompi_attr_create_predefined(void)
{ {
orte_gpr_notify_id_t rc; int rc;
int ret; orte_gpr_trigger_t trig, *trig1;
orte_gpr_value_t trig, *trig1; orte_gpr_value_t value, *values;
orte_gpr_subscription_t sub, *sub1; orte_gpr_subscription_t sub, *sub1;
orte_jobid_t job; orte_jobid_t job;
if (ORTE_SUCCESS != (ret = orte_ns.get_jobid(&job, orte_process_info.my_name))) { if (ORTE_SUCCESS != (rc = orte_ns.get_jobid(&job, orte_process_info.my_name))) {
ORTE_ERROR_LOG(ret); ORTE_ERROR_LOG(rc);
return ret; return rc;
} }
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t); OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
sub.addr_mode = ORTE_GPR_TOKENS_OR | ORTE_GPR_KEYS_OR; /* indicate that this is a standard subscription. This indicates that the
sub.segment = strdup(ORTE_NODE_SEGMENT); * subscription will be common to all processes. Thus, the resulting data
if (NULL == sub.segment) { * 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); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
sub.tokens = NULL; /* wildcard - look at all containers */ value.tokens = NULL; /* wildcard - look at all containers */
sub.num_tokens = 0; value.num_tokens = 0;
sub.num_keys = 1; value.cnt = 1;
sub.keys = (char**)malloc(sizeof(char*)); value.keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
if (NULL == sub.keys) { if (NULL == value.keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
sub.keys[0] = strdup(ORTE_NODE_SLOTS_KEY); value.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == sub.keys[0]) { if (NULL == value.keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); 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); OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
@ -103,70 +138,38 @@ int ompi_attr_create_predefined(void)
sub.user_tag = NULL; sub.user_tag = NULL;
/* setup the trigger information */ /* setup the trigger information */
OBJ_CONSTRUCT(&trig, orte_gpr_value_t); OBJ_CONSTRUCT(&trig, orte_gpr_trigger_t);
trig.addr_mode = ORTE_GPR_TOKENS_XAND; if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
if (ORTE_SUCCESS != (ret = orte_schema.get_job_segment_name(&(trig.segment), job))) { ORTE_STG1_TRIGGER, job))) {
ORTE_ERROR_LOG(ret); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig); return rc;
return ret;
} }
trig.tokens = (char**)malloc(sizeof(char*));
if (NULL == trig.tokens) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.tokens[0] = strdup(ORTE_JOB_GLOBALS);
trig.num_tokens = 1;
trig.cnt = 2; /* this is an ORTE-standard trigger that is defined by the ORTE resource manager
trig.keyvals = (orte_gpr_keyval_t**)malloc(2*sizeof(orte_gpr_keyval_t*)); * when the job was launched - therefore, we don't need to provide any additional
if (NULL == trig.keyvals) { * info
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); */
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trig.keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[0]->key = strdup(ORTE_JOB_SLOTS_KEY);
trig.keyvals[0]->type = ORTE_NULL;
trig.keyvals[1] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trig.keyvals[1]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[1]->key = strdup(ORTE_PROC_NUM_AT_STG1);
trig.keyvals[1]->type = ORTE_NULL;
/* do the subscription */ /* do the subscription */
sub1 = ⊂ sub1 = ⊂
trig1 = &trig; trig1 = &trig;
ret = orte_gpr.subscribe( rc = orte_gpr.subscribe(1, &sub1, 1, &trig1);
ORTE_GPR_TRIG_CMP_LEVELS | ORTE_GPR_TRIG_MONITOR_ONLY | if(ORTE_SUCCESS != rc) {
ORTE_GPR_TRIG_ONE_SHOT, ompi_output(0, "ompi_attr_create_predefined: subscribe failed");
1, &sub1, OBJ_DESTRUCT(&value);
1, &trig1, sub.values = NULL;
&rc); OBJ_DESTRUCT(&sub);
if(ORTE_SUCCESS != ret) { OBJ_DESTRUCT(&trig);
ompi_output(0, "ompi_attr_create_predefined: subscribe failed"); return OMPI_ERROR;
OBJ_DESTRUCT(&sub); }
OBJ_DESTRUCT(&trig); OBJ_DESTRUCT(&value);
return OMPI_ERROR; sub.values = NULL;
} OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&trig);
OBJ_DESTRUCT(&trig); return OMPI_SUCCESS;
return OMPI_SUCCESS;
} }

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

@ -74,5 +74,13 @@ enum {
#define OMPI_NAMESPACE_SEGMENT "ompi-namespace" #define OMPI_NAMESPACE_SEGMENT "ompi-namespace"
/*
* OMPI-specific names for triggers and subscriptions used across processes
*/
#define OMPI_ATTRIBUTE_SUBSCRIPTION "ompi-attribute-sub"
#define OMPI_OOB_SUBSCRIPTION "ompi-oob-sub"
#define OMPI_MODEX_SUBSCRIPTION "ompi-modex-sub"
#endif /* OMPI_CONSTANTS_H */ #endif /* OMPI_CONSTANTS_H */

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

@ -72,16 +72,19 @@ typedef uint8_t orte_data_type_t ;
#define ORTE_EXIT_CODE (orte_data_type_t) 32 /**< process exit code */ #define ORTE_EXIT_CODE (orte_data_type_t) 32 /**< process exit code */
/* GPR types */ /* GPR types */
#define ORTE_KEYVAL (orte_data_type_t) 33 /**< registry key-value pair */ #define ORTE_KEYVAL (orte_data_type_t) 33 /**< registry key-value pair */
#define ORTE_NOTIFY_ACTION (orte_data_type_t) 34 /**< registry notify action */ #define ORTE_GPR_NOTIFY_ACTION (orte_data_type_t) 34 /**< registry notify action */
#define ORTE_GPR_CMD (orte_data_type_t) 35 /**< registry command */ #define ORTE_GPR_TRIGGER_ACTION (orte_data_type_t) 35 /**< registry trigger action */
#define ORTE_GPR_NOTIFY_ID (orte_data_type_t) 36 /**< registry notify id tag */ #define ORTE_GPR_CMD (orte_data_type_t) 36 /**< registry command */
#define ORTE_GPR_VALUE (orte_data_type_t) 37 /**< registry return value */ #define ORTE_GPR_SUBSCRIPTION_ID (orte_data_type_t) 37 /**< registry notify id tag */
#define ORTE_GPR_ADDR_MODE (orte_data_type_t) 38 /**< Addressing mode for registry cmds */ #define ORTE_GPR_TRIGGER_ID (orte_data_type_t) 38 /**< registry notify id tag */
#define ORTE_GPR_SUBSCRIPTION (orte_data_type_t) 39 /**< describes data returned by subscription */ #define ORTE_GPR_VALUE (orte_data_type_t) 39 /**< registry return value */
#define ORTE_GPR_NOTIFY_DATA (orte_data_type_t) 40 /**< data returned from a subscription */ #define ORTE_GPR_ADDR_MODE (orte_data_type_t) 40 /**< Addressing mode for registry cmds */
#define ORTE_GPR_SUBSCRIPTION (orte_data_type_t) 41 /**< describes data returned by subscription */
#define ORTE_GPR_TRIGGER (orte_data_type_t) 42 /**< describes trigger conditions */
#define ORTE_GPR_NOTIFY_DATA (orte_data_type_t) 43 /**< data returned from a subscription */
/* Resource Manager types */ /* Resource Manager types */
#define ORTE_APP_CONTEXT (orte_data_type_t) 41 /**< argv and enviro arrays */ #define ORTE_APP_CONTEXT (orte_data_type_t) 44 /**< argv and enviro arrays */
#define ORTE_APP_CONTEXT_MAP (orte_data_type_t) 42 /**< application context mapping array */ #define ORTE_APP_CONTEXT_MAP (orte_data_type_t) 45 /**< application context mapping array */
/* define the starting point for dynamically assigning data types */ /* define the starting point for dynamically assigning data types */
#define ORTE_DPS_ID_DYNAMIC 50 #define ORTE_DPS_ID_DYNAMIC 50

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

@ -26,6 +26,7 @@
#include "mca/base/base.h" #include "mca/base/base.h"
#include "mca/errmgr/errmgr.h" #include "mca/errmgr/errmgr.h"
#include "mca/rml/rml.h" #include "mca/rml/rml.h"
#include "mca/schema/schema.h"
#include "mca/gpr/gpr.h" #include "mca/gpr/gpr.h"
#include "mca/gpr/base/base.h" #include "mca/gpr/base/base.h"
#include "mca/ns/ns.h" #include "mca/ns/ns.h"
@ -373,8 +374,7 @@ ompi_output(0, "[%lu,%lu,%lu] mca_base_modex_registry_callback: %s-%s-%d-%d rece
static int mca_base_modex_subscribe(orte_process_name_t* name) static int mca_base_modex_subscribe(orte_process_name_t* name)
{ {
orte_gpr_notify_id_t rctag; orte_gpr_trigger_t trig, *trigs;
orte_gpr_value_t trig, *trigs;
orte_gpr_subscription_t sub, *subs; orte_gpr_subscription_t sub, *subs;
orte_jobid_t jobid; orte_jobid_t jobid;
ompi_list_item_t* item; ompi_list_item_t* item;
@ -404,90 +404,96 @@ static int mca_base_modex_subscribe(orte_process_name_t* name)
/* setup the subscription definition */ /* setup the subscription definition */
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t); OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(sub.segment), jobid))) { /* 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_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); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
return rc; return rc;
} }
sub.addr_mode = ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR; sub.values[0]->addr_mode = ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR;
sub.tokens = NULL; /* look at all containers on this segment */
sub.num_tokens = 0; sub.values[0]->tokens = NULL;
sub.num_keys = 1; sub.values[0]->num_tokens = 0;
sub.keys = (char**)malloc(sizeof(char*)); /* look for any keyval with "modex" key */
if (NULL == sub.keys) { 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); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
sub.keys[0] = strdup("modex"); sub.values[0]->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == sub.keys[0]) { if (NULL == sub.values[0]->keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE; 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_base_modex_registry_callback; sub.cbfunc = mca_base_modex_registry_callback;
sub.user_tag = NULL; sub.user_tag = NULL;
/* setup the trigger definition */ /* setup the trigger definition */
OBJ_CONSTRUCT(&trig, orte_gpr_value_t); OBJ_CONSTRUCT(&trig, orte_gpr_trigger_t);
trig.addr_mode = ORTE_GPR_TOKENS_XAND; if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(trig.segment), jobid))) { ORTE_STG1_TRIGGER, jobid))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return rc; return rc;
} }
trig.tokens = (char**)malloc(sizeof(char*));
if (NULL == trig.tokens) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.tokens[0] = strdup(ORTE_JOB_GLOBALS);
trig.num_tokens = 1;
trig.cnt = 2;
trig.keyvals = (orte_gpr_keyval_t**)malloc(2*sizeof(orte_gpr_keyval_t*));
if (NULL == trig.keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trig.keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[0]->key = strdup(ORTE_JOB_SLOTS_KEY);
trig.keyvals[0]->type = ORTE_NULL;
trig.keyvals[1] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trig.keyvals[1]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[1]->key = strdup(ORTE_PROC_NUM_AT_STG1);
trig.keyvals[1]->type = ORTE_NULL;
/* 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 */ /* register the subscription */
subs = &sub; subs = &sub;
trigs = &trig; trigs = &trig;
rc = orte_gpr.subscribe( rc = orte_gpr.subscribe(1, &subs, 1, &trigs);
ORTE_GPR_NOTIFY_ADD_ENTRY | ORTE_GPR_NOTIFY_VALUE_CHG |
ORTE_GPR_TRIG_CMP_LEVELS | ORTE_GPR_TRIG_ONE_SHOT |
ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG,
1, &subs,
1, &trigs,
&rctag);
if(ORTE_SUCCESS != rc) { if(ORTE_SUCCESS != rc) {
ompi_output(0, "mca_base_modex_exchange: " ompi_output(0, "mca_base_modex_exchange: "
"ompi_gpr.subscribe failed with return code %d\n", rc); "orte_gpr.subscribe failed with return code %d\n", rc);
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig); OBJ_DESTRUCT(&trig);
return OMPI_ERROR; return OMPI_ERROR;

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

@ -52,7 +52,7 @@
*/ */
#ifndef ORTE_GPR_BASE_H_ #ifndef ORTE_GPR_BASE_H_
#define ORTE_GRP_BASE_H_ #define ORTE_GPR_BASE_H_
/* /*
* includes * includes
@ -83,16 +83,32 @@ extern "C" {
#endif #endif
/* /*
* packing type definitions for GPR-specific types * Define flag values for remote commands
*/ */
/* CAUTION - any changes here must also change corresponding #define ORTE_GPR_DELETE_SEGMENT_CMD (uint8_t) 1
* typedefs in gpr_types.h #define ORTE_GPR_PUT_CMD (uint8_t) 2
*/ #define ORTE_GPR_DELETE_ENTRIES_CMD (uint8_t) 3
#define ORTE_GPR_PACK_CMD ORTE_GPR_CMD #define ORTE_GPR_INDEX_CMD (uint8_t) 4
#define ORTE_GPR_PACK_ACTION ORTE_NOTIFY_ACTION #define ORTE_GPR_SUBSCRIBE_CMD (uint8_t) 5
#define ORTE_GPR_PACK_ADDR_MODE ORTE_UINT16 #define ORTE_GPR_UNSUBSCRIBE_CMD (uint8_t) 6
#define ORTE_GPR_PACK_SYNCHRO_MODE ORTE_SYNCHRO_MODE #define ORTE_GPR_CANCEL_TRIGGER_CMD (uint8_t) 7
#define ORTE_GPR_PACK_NOTIFY_ID ORTE_UINT32 #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
typedef uint8_t orte_gpr_cmd_flag_t;
#define ORTE_GPR_CMD_T ORTE_UINT8
OMPI_DECLSPEC int orte_gpr_base_open(void); OMPI_DECLSPEC int orte_gpr_base_open(void);
OMPI_DECLSPEC int orte_gpr_base_select(void); OMPI_DECLSPEC int orte_gpr_base_select(void);
@ -113,16 +129,19 @@ extern "C" {
char **index); char **index);
OMPI_DECLSPEC int orte_gpr_base_pack_subscribe(orte_buffer_t *cmd, OMPI_DECLSPEC int orte_gpr_base_pack_subscribe(orte_buffer_t *cmd,
orte_gpr_notify_action_t action, size_t num_subs, size_t num_subs,
orte_gpr_subscription_t **subscriptions, orte_gpr_subscription_t **subscriptions,
size_t num_trigs, orte_gpr_value_t **trig); size_t num_trigs, orte_gpr_trigger_t **trig);
OMPI_DECLSPEC int orte_gpr_base_unpack_subscribe(orte_buffer_t *buffer, int *ret, OMPI_DECLSPEC int orte_gpr_base_unpack_subscribe(orte_buffer_t *buffer, int *ret);
orte_gpr_notify_id_t *remote_idtag);
OMPI_DECLSPEC int orte_gpr_base_pack_unsubscribe(orte_buffer_t *cmd, OMPI_DECLSPEC int orte_gpr_base_pack_unsubscribe(orte_buffer_t *cmd,
orte_gpr_notify_id_t remote_idtag); 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_unpack_unsubscribe(orte_buffer_t *buffer, int *ret);
OMPI_DECLSPEC int orte_gpr_base_pack_cancel_trigger(orte_buffer_t *cmd,
orte_gpr_trigger_id_t id);
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, 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_unpack_put(orte_buffer_t *buffer, int *ret);
@ -136,6 +155,7 @@ extern "C" {
OMPI_DECLSPEC int orte_gpr_base_pack_dump_all(orte_buffer_t *cmd); 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); OMPI_DECLSPEC int orte_gpr_base_pack_dump_segments(orte_buffer_t *cmd);
OMPI_DECLSPEC int orte_gpr_base_pack_dump_triggers(orte_buffer_t *cmd); 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_callbacks(orte_buffer_t *cmd); 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 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, OMPI_DECLSPEC void orte_gpr_base_dump_keyval_value(orte_buffer_t *buffer,
@ -166,12 +186,18 @@ extern "C" {
int orte_gpr_base_pack_cmd(orte_buffer_t *buffer, void *src, int orte_gpr_base_pack_cmd(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type); size_t num_vals, orte_data_type_t type);
int orte_gpr_base_pack_notify_id(orte_buffer_t *buffer, void *src, int orte_gpr_base_pack_subscription_id(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type);
int orte_gpr_base_pack_trigger_id(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type); size_t num_vals, orte_data_type_t type);
int orte_gpr_base_pack_notify_action(orte_buffer_t *buffer, void *src, int orte_gpr_base_pack_notify_action(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type); size_t num_vals, orte_data_type_t type);
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_addr_mode(orte_buffer_t *buffer, void *src, int orte_gpr_base_pack_addr_mode(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type); size_t num_vals, orte_data_type_t type);
@ -184,6 +210,9 @@ int orte_gpr_base_pack_value(orte_buffer_t *buffer, void *src,
int orte_gpr_base_pack_subscription(orte_buffer_t *buffer, void *src, int orte_gpr_base_pack_subscription(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type); size_t num_vals, orte_data_type_t type);
int orte_gpr_base_pack_trigger(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type);
int orte_gpr_base_pack_notify_data(orte_buffer_t *buffer, void *src, int orte_gpr_base_pack_notify_data(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type); size_t num_vals, orte_data_type_t type);
@ -191,12 +220,18 @@ int orte_gpr_base_pack_notify_data(orte_buffer_t *buffer, void *src,
int orte_gpr_base_unpack_cmd(orte_buffer_t *buffer, void *dest, int orte_gpr_base_unpack_cmd(orte_buffer_t *buffer, void *dest,
size_t *num_vals, orte_data_type_t type); size_t *num_vals, orte_data_type_t type);
int orte_gpr_base_unpack_notify_id(orte_buffer_t *buffer, void *dest, int orte_gpr_base_unpack_subscription_id(orte_buffer_t *buffer, void *dest,
size_t *num_vals, orte_data_type_t type);
int orte_gpr_base_unpack_trigger_id(orte_buffer_t *buffer, void *dest,
size_t *num_vals, orte_data_type_t type); size_t *num_vals, orte_data_type_t type);
int orte_gpr_base_unpack_notify_action(orte_buffer_t *buffer, void *dest, int orte_gpr_base_unpack_notify_action(orte_buffer_t *buffer, void *dest,
size_t *num_vals, orte_data_type_t type); size_t *num_vals, orte_data_type_t type);
int orte_gpr_base_unpack_trigger_action(orte_buffer_t *buffer, void *dest,
size_t *num_vals, orte_data_type_t type);
int orte_gpr_base_unpack_addr_mode(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); size_t *num_vals, orte_data_type_t type);
@ -209,6 +244,9 @@ int orte_gpr_base_unpack_value(orte_buffer_t *buffer, void *dest,
int orte_gpr_base_unpack_subscription(orte_buffer_t *buffer, void *dest, int orte_gpr_base_unpack_subscription(orte_buffer_t *buffer, void *dest,
size_t *num_vals, orte_data_type_t type); size_t *num_vals, orte_data_type_t type);
int orte_gpr_base_unpack_trigger(orte_buffer_t *buffer, void *dest,
size_t *num_vals, orte_data_type_t type);
int orte_gpr_base_unpack_notify_data(orte_buffer_t *buffer, void *dest, int orte_gpr_base_unpack_notify_data(orte_buffer_t *buffer, void *dest,
size_t *num_vals, orte_data_type_t type); size_t *num_vals, orte_data_type_t type);

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

@ -42,14 +42,29 @@ int orte_gpr_base_pack_cmd(orte_buffer_t *buffer, void *src,
} }
/* /*
* NOTIFY ID * SUBSCRIPTION ID
*/ */
int orte_gpr_base_pack_notify_id(orte_buffer_t *buffer, void *src, int orte_gpr_base_pack_subscription_id(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type) size_t num_vals, orte_data_type_t type)
{ {
int rc; int rc;
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_GPR_NOTIFY_ID_T))) { if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_GPR_SUBSCRIPTION_ID_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
/*
* TRIGGER ID
*/
int orte_gpr_base_pack_trigger_id(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_TRIGGER_ID_T))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
} }
@ -71,6 +86,21 @@ int orte_gpr_base_pack_notify_action(orte_buffer_t *buffer, void *src,
return rc; return rc;
} }
/*
* TRIGGER ACTION
*/
int orte_gpr_base_pack_trigger_action(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_TRIGGER_ACTION_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
/* /*
* ADDR MODE * ADDR MODE
*/ */
@ -202,58 +232,103 @@ int orte_gpr_base_pack_subscription(orte_buffer_t *buffer, void *src,
/* array of pointers to subscription objects - need to pack the objects */ /* array of pointers to subscription objects - need to pack the objects */
subs = (orte_gpr_subscription_t**) src; subs = (orte_gpr_subscription_t**) src;
for (i=0; i<num_vals; i++) { for (i=0; i<num_vals; i++) {
/* pack the address mode */ /* pack the subscription name */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(subs[i]->addr_mode)), 1, ORTE_GPR_ADDR_MODE))) { (void*)(&(subs[i]->name)), 1, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* pack the segment name */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(subs[i]->segment)), 1, ORTE_STRING))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
/* pack the number of tokens so we can read it for unpacking */ /* pack the subscription id */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(subs[i]->num_tokens)), 1, DPS_TYPE_SIZE_T))) { (void*)(&(subs[i]->id)), 1, ORTE_GPR_SUBSCRIPTION_ID))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
/* if there are tokens, pack them */ /* pack the notify action */
if (0 < subs[i]->num_tokens) { if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(subs[i]->action)), 1, ORTE_GPR_NOTIFY_ACTION))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* pack the number of values so we can read it for unpacking */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(subs[i]->cnt)), 1, DPS_TYPE_SIZE_T))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* if there are values, pack them */
if (0 < subs[i]->cnt) {
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)((subs[i]->tokens)), subs[i]->num_tokens, ORTE_STRING))) { (void*)((subs[i]->values)), subs[i]->cnt, ORTE_GPR_VALUE))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
} }
/* pack the number of keys so we can read it for unpacking */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(subs[i]->num_keys)), 1, DPS_TYPE_SIZE_T))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* if there are keys, pack them */
if (0 < subs[i]->num_keys) {
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)((subs[i]->keys)), subs[i]->num_keys, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
/* skip the pointers for cb_func and user_tag */ /* skip the pointers for cb_func and user_tag */
} }
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
/*
* TRIGGER
*/
int orte_gpr_base_pack_trigger(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type)
{
int rc;
orte_gpr_trigger_t **trigs;
size_t i;
/* array of pointers to trigger objects - need to pack the objects */
trigs = (orte_gpr_trigger_t**) src;
for (i=0; i<num_vals; i++) {
/* pack the trigger name */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(trigs[i]->name)), 1, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* pack the trigger id */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(trigs[i]->id)), 1, ORTE_GPR_TRIGGER_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* pack the trigger action */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(trigs[i]->action)), 1, ORTE_GPR_TRIGGER_ACTION))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* pack the number of values so we can read it for unpacking */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(trigs[i]->cnt)), 1, DPS_TYPE_SIZE_T))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* if there are values, pack the values */
if (0 < trigs[i]->cnt) {
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)((trigs[i]->values)), trigs[i]->cnt, ORTE_GPR_VALUE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
}
return ORTE_SUCCESS;
}
/* /*
* NOTIFY DATA * NOTIFY DATA
*/ */
@ -269,23 +344,9 @@ int orte_gpr_base_pack_notify_data(orte_buffer_t *buffer, void *src,
for (i=0; i<num_vals; i++) { for (i=0; i<num_vals; i++) {
/* pack the callback number */ /* pack the subscription number */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(data[i]->cb_num)), 1, DPS_TYPE_SIZE_T))) { (void*)(&(data[i]->id)), 1, ORTE_GPR_SUBSCRIPTION_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* pack the address mode */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(data[i]->addr_mode)), 1, ORTE_GPR_ADDR_MODE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* pack the segment name */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(data[i]->segment)), 1, ORTE_STRING))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }

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

@ -42,14 +42,29 @@ int orte_gpr_base_unpack_cmd(orte_buffer_t *buffer, void *dest,
} }
/* /*
* NOTIFY ID * SUBSCRIPTION ID
*/ */
int orte_gpr_base_unpack_notify_id(orte_buffer_t *buffer, void *dest, int orte_gpr_base_unpack_subscription_id(orte_buffer_t *buffer, void *dest,
size_t *num_vals, orte_data_type_t type) size_t *num_vals, orte_data_type_t type)
{ {
int rc; int rc;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_GPR_NOTIFY_ID_T))) { if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_GPR_SUBSCRIPTION_ID_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
/*
* TRIGGER ID
*/
int orte_gpr_base_unpack_trigger_id(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_TRIGGER_ID_T))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
} }
@ -71,6 +86,21 @@ int orte_gpr_base_unpack_notify_action(orte_buffer_t *buffer, void *dest,
return rc; return rc;
} }
/*
* TRIGGER ACTION
*/
int orte_gpr_base_unpack_trigger_action(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_TRIGGER_ACTION_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
/* /*
* ADDR MODE * ADDR MODE
*/ */
@ -235,61 +265,45 @@ int orte_gpr_base_unpack_subscription(orte_buffer_t *buffer, void *dest,
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
/* unpack the address mode */ /* unpack the subscription name */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(subs[i]->addr_mode), if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(subs[i]->name),
&max_n, ORTE_GPR_ADDR_MODE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* unpack the segment name */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(subs[i]->segment),
&max_n, ORTE_STRING))) { &max_n, ORTE_STRING))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
/* get the number of tokens */ /* unpack the subscription id */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(subs[i]->num_tokens), if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(subs[i]->id),
&max_n, ORTE_GPR_SUBSCRIPTION_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* unpack the subscription action */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(subs[i]->action),
&max_n, ORTE_GPR_NOTIFY_ACTION))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* get the number of values */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(subs[i]->cnt),
&max_n, DPS_TYPE_SIZE_T))) { &max_n, DPS_TYPE_SIZE_T))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
/* if there are tokens, allocate the required space for the char * pointers */ /* if there are values, allocate the required space for the value pointers */
if (0 < subs[i]->num_tokens) { if (0 < subs[i]->cnt) {
subs[i]->tokens = (char **)malloc(subs[i]->num_tokens * sizeof(char*)); subs[i]->values = (orte_gpr_value_t**)malloc(subs[i]->cnt * sizeof(orte_gpr_value_t*));
if (NULL == subs[i]->tokens) { if (NULL == subs[i]->values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
/* and unpack them */ /* and unpack them */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, subs[i]->tokens, if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, subs[i]->values,
&(subs[i]->num_tokens), ORTE_STRING))) { &(subs[i]->cnt), ORTE_GPR_VALUE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
/* get the number of keys */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(subs[i]->num_keys),
&max_n, DPS_TYPE_SIZE_T))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* if there are keys, allocate the required space for the char * pointers */
if (0 < subs[i]->num_keys) {
subs[i]->keys = (char **)malloc(subs[i]->num_keys * sizeof(char*));
if (NULL == subs[i]->keys) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* and unpack them */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, subs[i]->keys,
&(subs[i]->num_keys), ORTE_STRING))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
@ -303,6 +317,74 @@ int orte_gpr_base_unpack_subscription(orte_buffer_t *buffer, void *dest,
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
/*
* TRIGGER
*/
int orte_gpr_base_unpack_trigger(orte_buffer_t *buffer, void *dest,
size_t *num_vals, orte_data_type_t type)
{
int rc;
orte_gpr_trigger_t **trigs;
size_t i, max_n=1;
/* unpack into array of trigger objects */
trigs = (orte_gpr_trigger_t**) dest;
for (i=0; i < *num_vals; i++) {
/* create the trigger object */
trigs[i] = OBJ_NEW(orte_gpr_trigger_t);
if (NULL == trigs[i]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* unpack the trigger name */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(trigs[i]->name),
&max_n, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* unpack the trigger id */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(trigs[i]->id),
&max_n, ORTE_GPR_TRIGGER_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* unpack the trigger action */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(trigs[i]->action),
&max_n, ORTE_GPR_TRIGGER_ACTION))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* get the number of values */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(trigs[i]->cnt),
&max_n, DPS_TYPE_SIZE_T))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* if there are values, allocate the required space for the value pointers */
if (0 < trigs[i]->cnt) {
trigs[i]->values = (orte_gpr_value_t**)malloc(trigs[i]->cnt * sizeof(orte_gpr_value_t*));
if (NULL == trigs[i]->values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* and unpack them */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, trigs[i]->values,
&(trigs[i]->cnt), ORTE_GPR_VALUE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
}
return ORTE_SUCCESS;
}
/* /*
* NOTIFY DATA * NOTIFY DATA
*/ */
@ -324,23 +406,9 @@ int orte_gpr_base_unpack_notify_data(orte_buffer_t *buffer, void *dest,
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
/* unpack the callback number */ /* unpack the subscription number */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(data[i]->cb_num), if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(data[i]->id),
&max_n, DPS_TYPE_SIZE_T))) { &max_n, ORTE_GPR_SUBSCRIPTION_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* unpack the address mode */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(data[i]->addr_mode),
&max_n, ORTE_GPR_ADDR_MODE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* unpack the segment name */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(data[i]->segment),
&max_n, ORTE_STRING))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }

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

@ -44,7 +44,7 @@
static void orte_gpr_keyval_construct(orte_gpr_keyval_t* keyval) static void orte_gpr_keyval_construct(orte_gpr_keyval_t* keyval)
{ {
keyval->key = NULL; keyval->key = NULL;
keyval->type = 0; keyval->type = ORTE_NULL;
keyval->value.i32 = 0; keyval->value.i32 = 0;
} }
@ -88,7 +88,7 @@ static void orte_gpr_value_construct(orte_gpr_value_t* reg_val)
reg_val->cnt = 0; reg_val->cnt = 0;
reg_val->keyvals = NULL; reg_val->keyvals = NULL;
reg_val->num_tokens = 0; reg_val->num_tokens = 0;
reg_val->tokens = 0; reg_val->tokens = NULL;
} }
/* destructor - used to free any resources held by instance */ /* destructor - used to free any resources held by instance */
@ -129,9 +129,7 @@ OBJ_CLASS_INSTANCE(
/* constructor - used to initialize state of registry value instance */ /* constructor - used to initialize state of registry value instance */
static void orte_gpr_notify_data_construct(orte_gpr_notify_data_t* ptr) static void orte_gpr_notify_data_construct(orte_gpr_notify_data_t* ptr)
{ {
ptr->cb_num = 0; ptr->id = ORTE_GPR_SUBSCRIPTION_ID_MAX;
ptr->addr_mode = 0;
ptr->segment = NULL;
ptr->cnt = 0; ptr->cnt = 0;
ptr->values = NULL; ptr->values = NULL;
} }
@ -141,8 +139,6 @@ static void orte_gpr_notify_data_destructor(orte_gpr_notify_data_t* ptr)
{ {
size_t i; size_t i;
if (NULL != ptr->segment) free(ptr->segment);
if (0 < ptr->cnt && NULL != ptr->values) { if (0 < ptr->cnt && NULL != ptr->values) {
for (i=0; i < ptr->cnt; i++) { for (i=0; i < ptr->cnt; i++) {
if (NULL != ptr->values[i]) if (NULL != ptr->values[i])
@ -164,12 +160,11 @@ OBJ_CLASS_INSTANCE(
/* constructor - used to initialize state of registry subscription instance */ /* constructor - used to initialize state of registry subscription instance */
static void orte_gpr_subscription_construct(orte_gpr_subscription_t* sub) static void orte_gpr_subscription_construct(orte_gpr_subscription_t* sub)
{ {
sub->addr_mode = 0; sub->name = NULL;
sub->segment = NULL; sub->id = ORTE_GPR_SUBSCRIPTION_ID_MAX;
sub->num_tokens = 0; sub->action = 0;
sub->tokens = NULL; sub->cnt = 0;
sub->num_keys = 0; sub->values = NULL;
sub->keys = NULL;
sub->cbfunc = NULL; sub->cbfunc = NULL;
sub->user_tag = NULL; sub->user_tag = NULL;
} }
@ -177,29 +172,16 @@ static void orte_gpr_subscription_construct(orte_gpr_subscription_t* sub)
/* destructor - used to free any resources held by instance */ /* destructor - used to free any resources held by instance */
static void orte_gpr_subscription_destructor(orte_gpr_subscription_t* sub) static void orte_gpr_subscription_destructor(orte_gpr_subscription_t* sub)
{ {
char **tokens;
size_t i; size_t i;
if (NULL != sub->segment) free(sub->segment); if (NULL != sub->name) free(sub->name);
if (0 < sub->num_tokens && NULL != sub->tokens) { if (0 < sub->cnt && NULL != sub->values) {
tokens = sub->tokens; for (i=0; i < sub->cnt; i++) {
for (i=0; i < sub->num_tokens; i++) { OBJ_RELEASE(sub->values[i]);
if(NULL != tokens[i])
free(tokens[i]);
} }
free(sub->tokens); free(sub->values);
} }
if (0 < sub->num_keys && NULL != sub->keys) {
tokens = sub->keys;
for (i=0; i < sub->num_keys; i++) {
if(NULL != tokens[i])
free(tokens[i]);
}
free(sub->keys);
}
} }
/* define instance of ompi_class_t */ /* define instance of ompi_class_t */
@ -210,11 +192,43 @@ OBJ_CLASS_INSTANCE(
orte_gpr_subscription_destructor); /* destructor */ orte_gpr_subscription_destructor); /* destructor */
/** TRIGGER **/
/* constructor - used to initialize state of registry subscription instance */
static void orte_gpr_trigger_construct(orte_gpr_trigger_t* trig)
{
trig->name = NULL;
trig->id = ORTE_GPR_TRIGGER_ID_MAX;
trig->action = 0;
trig->cnt = 0;
trig->values = NULL;
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_trigger_destructor(orte_gpr_trigger_t* trig)
{
size_t i;
if (NULL != trig->name) free(trig->name);
if (0 < trig->cnt && NULL != trig->values) {
for (i=0; i < trig->cnt; i++) OBJ_RELEASE(trig->values[i]);
free(trig->values);
}
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_trigger_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_trigger_construct, /* constructor */
orte_gpr_trigger_destructor); /* destructor */
/** NOTIFY MESSAGE */ /** NOTIFY MESSAGE */
/* constructor - used to initialize notify message instance */ /* constructor - used to initialize notify message instance */
static void orte_gpr_notify_message_construct(orte_gpr_notify_message_t* msg) static void orte_gpr_notify_message_construct(orte_gpr_notify_message_t* msg)
{ {
msg->idtag = 0;
msg->cnt = 0; msg->cnt = 0;
msg->data = NULL; msg->data = NULL;
} }
@ -281,18 +295,34 @@ int orte_gpr_base_open(void)
return rc; return rc;
} }
tmp = ORTE_GPR_NOTIFY_ID; tmp = ORTE_GPR_SUBSCRIPTION_ID;
if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_notify_id, if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_subscription_id,
orte_gpr_base_unpack_notify_id, orte_gpr_base_unpack_subscription_id,
"ORTE_GPR_NOTIFY_ID", &tmp))) { "ORTE_GPR_SUBSCRIPTION_ID", &tmp))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
tmp = ORTE_NOTIFY_ACTION; tmp = ORTE_GPR_TRIGGER_ID;
if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_trigger_id,
orte_gpr_base_unpack_trigger_id,
"ORTE_GPR_TRIGGER_ID", &tmp))) {
ORTE_ERROR_LOG(rc);
return rc;
}
tmp = ORTE_GPR_NOTIFY_ACTION;
if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_notify_action, if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_notify_action,
orte_gpr_base_unpack_notify_action, orte_gpr_base_unpack_notify_action,
"ORTE_NOTIFY_ACTION", &tmp))) { "ORTE_GPR_NOTIFY_ACTION", &tmp))) {
ORTE_ERROR_LOG(rc);
return rc;
}
tmp = ORTE_GPR_TRIGGER_ACTION;
if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_trigger_action,
orte_gpr_base_unpack_trigger_action,
"ORTE_GPR_TRIGGER_ACTION", &tmp))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
@ -329,6 +359,14 @@ int orte_gpr_base_open(void)
return rc; return rc;
} }
tmp = ORTE_GPR_TRIGGER;
if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_trigger,
orte_gpr_base_unpack_trigger,
"ORTE_GPR_TRIGGER", &tmp))) {
ORTE_ERROR_LOG(rc);
return rc;
}
tmp = ORTE_GPR_NOTIFY_DATA; tmp = ORTE_GPR_NOTIFY_DATA;
if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_notify_data, if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_notify_data,
orte_gpr_base_unpack_notify_data, orte_gpr_base_unpack_notify_data,

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

@ -39,7 +39,7 @@ int orte_gpr_base_pack_increment_value(orte_buffer_t *cmd, orte_gpr_value_t *val
command = ORTE_GPR_INCREMENT_VALUE_CMD; command = ORTE_GPR_INCREMENT_VALUE_CMD;
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
@ -60,7 +60,7 @@ int orte_gpr_base_pack_decrement_value(orte_buffer_t *cmd, orte_gpr_value_t *val
command = ORTE_GPR_DECREMENT_VALUE_CMD; command = ORTE_GPR_DECREMENT_VALUE_CMD;
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }

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

@ -36,7 +36,7 @@ int orte_gpr_base_pack_cleanup_job(orte_buffer_t *buffer, orte_jobid_t jobid)
command = ORTE_GPR_CLEANUP_JOB_CMD; command = ORTE_GPR_CLEANUP_JOB_CMD;
if (ORTE_SUCCESS != (rc = orte_dps.pack(buffer, &command, 1, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.pack(buffer, &command, 1, ORTE_GPR_CMD))) {
return rc; return rc;
} }
@ -55,7 +55,7 @@ int orte_gpr_base_pack_cleanup_proc(orte_buffer_t *buffer, orte_process_name_t *
command = ORTE_GPR_CLEANUP_PROC_CMD; command = ORTE_GPR_CLEANUP_PROC_CMD;
if (ORTE_SUCCESS != (rc = orte_dps.pack(buffer, &command, 1, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.pack(buffer, &command, 1, ORTE_GPR_CMD))) {
return rc; return rc;
} }

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

@ -33,7 +33,7 @@ int orte_gpr_base_pack_delete_segment(orte_buffer_t *cmd, char *segment)
command = ORTE_GPR_DELETE_SEGMENT_CMD; command = ORTE_GPR_DELETE_SEGMENT_CMD;
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD))) {
return rc; return rc;
} }

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

@ -36,7 +36,7 @@ int orte_gpr_base_pack_dump_all(orte_buffer_t *cmd)
command = ORTE_GPR_DUMP_ALL_CMD; command = ORTE_GPR_DUMP_ALL_CMD;
return orte_dps.pack(cmd, &command, 1, ORTE_GPR_PACK_CMD); return orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD);
} }
int orte_gpr_base_pack_dump_segments(orte_buffer_t *cmd) int orte_gpr_base_pack_dump_segments(orte_buffer_t *cmd)
@ -45,7 +45,7 @@ int orte_gpr_base_pack_dump_segments(orte_buffer_t *cmd)
command = ORTE_GPR_DUMP_SEGMENTS_CMD; command = ORTE_GPR_DUMP_SEGMENTS_CMD;
return orte_dps.pack(cmd, &command, 1, ORTE_GPR_PACK_CMD); return orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD);
} }
int orte_gpr_base_pack_dump_triggers(orte_buffer_t *cmd) int orte_gpr_base_pack_dump_triggers(orte_buffer_t *cmd)
@ -54,7 +54,16 @@ int orte_gpr_base_pack_dump_triggers(orte_buffer_t *cmd)
command = ORTE_GPR_DUMP_TRIGGERS_CMD; command = ORTE_GPR_DUMP_TRIGGERS_CMD;
return orte_dps.pack(cmd, &command, 1, ORTE_GPR_PACK_CMD); return orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD);
}
int orte_gpr_base_pack_dump_subscriptions(orte_buffer_t *cmd)
{
orte_gpr_cmd_flag_t command;
command = ORTE_GPR_DUMP_SUBSCRIPTIONS_CMD;
return orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD);
} }
int orte_gpr_base_pack_dump_callbacks(orte_buffer_t *cmd) int orte_gpr_base_pack_dump_callbacks(orte_buffer_t *cmd)
@ -63,5 +72,5 @@ int orte_gpr_base_pack_dump_callbacks(orte_buffer_t *cmd)
command = ORTE_GPR_DUMP_CALLBACKS_CMD; command = ORTE_GPR_DUMP_CALLBACKS_CMD;
return orte_dps.pack(cmd, &command, 1, ORTE_GPR_PACK_CMD); return orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD);
} }

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

@ -33,10 +33,10 @@
#include "mca/gpr/base/base.h" #include "mca/gpr/base/base.h"
int orte_gpr_base_pack_subscribe(orte_buffer_t *cmd, int orte_gpr_base_pack_subscribe(orte_buffer_t *cmd,
orte_gpr_notify_action_t action, size_t num_subs, size_t num_subs,
orte_gpr_subscription_t **subscriptions, orte_gpr_subscription_t **subscriptions,
size_t num_trigs, size_t num_trigs,
orte_gpr_value_t **trigs) orte_gpr_trigger_t **trigs)
{ {
orte_gpr_cmd_flag_t command; orte_gpr_cmd_flag_t command;
int rc; int rc;
@ -48,17 +48,12 @@ int orte_gpr_base_pack_subscribe(orte_buffer_t *cmd,
return rc; return rc;
} }
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &action, 1, ORTE_NOTIFY_ACTION))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, subscriptions, num_subs, ORTE_GPR_SUBSCRIPTION))) { if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, subscriptions, num_subs, ORTE_GPR_SUBSCRIPTION))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, trigs, num_trigs, ORTE_GPR_VALUE))) { if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, trigs, num_trigs, ORTE_GPR_TRIGGER))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
@ -68,20 +63,38 @@ int orte_gpr_base_pack_subscribe(orte_buffer_t *cmd,
int orte_gpr_base_pack_unsubscribe(orte_buffer_t *cmd, int orte_gpr_base_pack_unsubscribe(orte_buffer_t *cmd,
orte_gpr_notify_id_t remote_idtag) orte_gpr_subscription_id_t id)
{ {
orte_gpr_cmd_flag_t command; orte_gpr_cmd_flag_t command;
int rc; int rc;
command = ORTE_GPR_UNSUBSCRIBE_CMD; command = ORTE_GPR_UNSUBSCRIBE_CMD;
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_GPR_PACK_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, &remote_idtag, 1, ORTE_GPR_PACK_NOTIFY_ID))) { if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &id, 1, ORTE_GPR_SUBSCRIPTION_ID))) {
return rc; return rc;
} }
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
int orte_gpr_base_pack_cancel_trigger(orte_buffer_t *cmd, orte_gpr_trigger_id_t id)
{
orte_gpr_cmd_flag_t command;
int rc;
command = ORTE_GPR_CANCEL_TRIGGER_CMD;
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD))) {
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &id, 1, ORTE_GPR_TRIGGER_ID))) {
return rc;
}
return ORTE_SUCCESS;
}

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

@ -51,13 +51,13 @@ int orte_gpr_base_dump_notify_msg(orte_buffer_t *buffer,
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
asprintf(&tmp_out, "%lu Notify data structures in message going to trigger %lu", asprintf(&tmp_out, "%lu Notify data structures in message",
(unsigned long) msg->cnt, (unsigned long) msg->idtag); (unsigned long) msg->cnt);
orte_gpr_base_dump_load_string(buffer, &tmp_out); orte_gpr_base_dump_load_string(buffer, &tmp_out);
if (0 < msg->cnt && NULL != msg->data) { if (0 < msg->cnt && NULL != msg->data) {
for (i=0; i < msg->cnt; i++) { for (i=0; i < msg->cnt; i++) {
asprintf(&tmp_out, "\nDump of data structure %lu", asprintf(&tmp_out, "\nDump of notify data structure number %lu",
(unsigned long) i); (unsigned long) i);
orte_gpr_base_dump_load_string(buffer, &tmp_out); orte_gpr_base_dump_load_string(buffer, &tmp_out);
orte_gpr_base_dump_data(buffer, msg->data[i]); orte_gpr_base_dump_data(buffer, msg->data[i]);
@ -92,15 +92,14 @@ static void orte_gpr_base_dump_data(orte_buffer_t *buffer,
orte_gpr_value_t **values; orte_gpr_value_t **values;
size_t i; size_t i;
asprintf(&tmp_out, "%lu Values from segment %s", asprintf(&tmp_out, "%lu values going to subscription num %lu",
(unsigned long) data->cnt, data->segment); (unsigned long) data->cnt, (unsigned long) data->id);
orte_gpr_base_dump_load_string(buffer, &tmp_out); orte_gpr_base_dump_load_string(buffer, &tmp_out);
if (0 < data->cnt && NULL != data->values) { if (0 < data->cnt && NULL != data->values) {
values = data->values; values = data->values;
for (i=0; i < data->cnt; i++) { for (i=0; i < data->cnt; i++) {
asprintf(&tmp_out, "\nData for value %lu going to callback num %lu", asprintf(&tmp_out, "\nData for value %lu", (unsigned long) i);
(unsigned long) i, (unsigned long) data->cb_num);
orte_gpr_base_dump_load_string(buffer, &tmp_out); orte_gpr_base_dump_load_string(buffer, &tmp_out);
if (NULL == values[i]) { if (NULL == values[i]) {
asprintf(&tmp_out, "\tError encountered: NULL value pointer"); asprintf(&tmp_out, "\tError encountered: NULL value pointer");

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

@ -39,7 +39,7 @@ int orte_gpr_base_unpack_increment_value(orte_buffer_t *cmd, int *ret)
size_t n; size_t n;
n=1; n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(cmd, &command, &n, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(cmd, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
@ -66,7 +66,7 @@ int orte_gpr_base_unpack_decrement_value(orte_buffer_t *cmd, int *ret)
size_t n; size_t n;
n=1; n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(cmd, &command, &n, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(cmd, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }

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

@ -39,7 +39,7 @@ int orte_gpr_base_unpack_cleanup_job(orte_buffer_t *cmd, int *ret)
size_t n; size_t n;
n=1; n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(cmd, &command, &n, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(cmd, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
@ -65,7 +65,7 @@ int orte_gpr_base_unpack_cleanup_proc(orte_buffer_t *cmd, int *ret)
size_t n; size_t n;
n=1; n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(cmd, &command, &n, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(cmd, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }

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

@ -34,7 +34,7 @@ int orte_gpr_base_unpack_delete_segment(orte_buffer_t *buffer, int *ret)
size_t n; size_t n;
n = 1; n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
@ -60,7 +60,7 @@ int orte_gpr_base_unpack_delete_entries(orte_buffer_t *buffer, int *ret)
size_t n; size_t n;
n = 1; n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
@ -89,7 +89,7 @@ int orte_gpr_base_unpack_index(orte_buffer_t *buffer, int *ret, size_t *cnt, cha
*cnt = 0; *cnt = 0;
n = 1; n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }

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

@ -39,7 +39,7 @@ int orte_gpr_base_unpack_put(orte_buffer_t *buffer, int *ret)
size_t n; size_t n;
n=1; n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
@ -67,7 +67,7 @@ int orte_gpr_base_unpack_get(orte_buffer_t *buffer, int *ret, size_t *cnt, orte_
size_t n, num; size_t n, num;
n=1; n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }

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

@ -33,14 +33,14 @@
#include "mca/gpr/base/base.h" #include "mca/gpr/base/base.h"
int orte_gpr_base_unpack_subscribe(orte_buffer_t *buffer, int *ret, orte_gpr_notify_id_t *remote_idtag) int orte_gpr_base_unpack_subscribe(orte_buffer_t *buffer, int *ret)
{ {
orte_gpr_cmd_flag_t command; orte_gpr_cmd_flag_t command;
size_t n; size_t n;
int rc; int rc;
n = 1; n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
@ -50,12 +50,6 @@ int orte_gpr_base_unpack_subscribe(orte_buffer_t *buffer, int *ret, orte_gpr_not
return ORTE_ERR_COMM_FAILURE; return ORTE_ERR_COMM_FAILURE;
} }
n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, remote_idtag, &n, ORTE_GPR_NOTIFY_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
n = 1; n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, ret, &n, ORTE_INT))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, ret, &n, ORTE_INT))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
@ -73,7 +67,7 @@ int orte_gpr_base_unpack_unsubscribe(orte_buffer_t *buffer, int *ret)
int rc; int rc;
n = 1; n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_PACK_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
@ -91,3 +85,30 @@ int orte_gpr_base_unpack_unsubscribe(orte_buffer_t *buffer, int *ret)
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
int orte_gpr_base_unpack_cancel_trigger(orte_buffer_t *buffer, int *ret)
{
orte_gpr_cmd_flag_t command;
size_t n;
int rc;
n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_GPR_CANCEL_TRIGGER_CMD != command) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
return ORTE_ERR_COMM_FAILURE;
}
n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, ret, &n, ORTE_INT))) {
ORTE_ERROR_LOG(rc);
return rc;
}
return ORTE_SUCCESS;
}

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

@ -420,7 +420,7 @@ typedef int (*orte_gpr_base_module_index_nb_fn_t)(char *segment,
* *
* @param num_trigs (IN) The number of trigger objects being provided * @param num_trigs (IN) The number of trigger objects being provided
* *
* @param **trig_value (IN) A pointer to an array of orte_gpr_value_t objects that describe the * @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 * 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 * to the callback function. Trigger messages include all data specified in the
* subscription objects, but do NOT include the trigger counters themselves unless * subscription objects, but do NOT include the trigger counters themselves unless
@ -444,19 +444,17 @@ typedef int (*orte_gpr_base_module_index_nb_fn_t)(char *segment,
* @endcode * @endcode
*/ */
typedef int (*orte_gpr_base_module_subscribe_fn_t)( typedef int (*orte_gpr_base_module_subscribe_fn_t)(
orte_gpr_notify_action_t actions,
size_t num_subs, size_t num_subs,
orte_gpr_subscription_t **subscriptions, orte_gpr_subscription_t **subscriptions,
size_t num_trigs, size_t num_trigs,
orte_gpr_value_t **trig_value, orte_gpr_trigger_t **triggers);
orte_gpr_notify_id_t *sub_number);
/* /*
* Cancel a subscription. * Cancel a subscription.
* Once a subscription has been entered on the registry, a caller may choose to permanently * Once a subscription has been entered on the registry, a caller may choose to permanently
* remove it at a later time. This function supports that request. * remove it at a later time. This function supports that request.
* *
* @param sub_number The orte_gpr_notify_id_t value returned by the original subscribe * @param sub_number The orte_gpr_subscription_id_t value returned by the original subscribe
* command. * command.
* *
* @retval ORTE_SUCCESS The subscription was removed. * @retval ORTE_SUCCESS The subscription was removed.
@ -467,7 +465,26 @@ typedef int (*orte_gpr_base_module_subscribe_fn_t)(
* status_code = orte_gpr.unsubscribe(sub_number); * status_code = orte_gpr.unsubscribe(sub_number);
* @endcode * @endcode
*/ */
typedef int (*orte_gpr_base_module_unsubscribe_fn_t)(orte_gpr_notify_id_t sub_number); typedef int (*orte_gpr_base_module_unsubscribe_fn_t)(orte_gpr_subscription_id_t sub_number);
/*
* Cancel a trigger.
* Once a trigger has been entered on the registry, a caller may choose to permanently
* remove it at a later time. This function supports that request.
*
* @param trig_number The orte_gpr_trigger_id_t value returned by the original subscribe
* command.
*
* @retval ORTE_SUCCESS The trigger was removed.
* @retval ORTE_ERROR The trigger could not be removed - most likely caused by specifying
* a non-existent (or previously removed) trigger number.
*
* @code
* status_code = orte_gpr.cancel_trigger(trig_number);
* @endcode
*/
typedef int (*orte_gpr_base_module_cancel_trigger_fn_t)(orte_gpr_trigger_id_t trig_number);
/* Output the registry's contents to an output stream /* Output the registry's contents to an output stream
* For debugging purposes, it is helpful to be able to obtain a complete formatted printout * For debugging purposes, it is helpful to be able to obtain a complete formatted printout
@ -489,6 +506,8 @@ typedef int (*orte_gpr_base_module_dump_segments_fn_t)(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)(int output_id);
typedef int (*orte_gpr_base_module_dump_subscriptions_fn_t)(int output_id);
typedef int (*orte_gpr_base_module_dump_callbacks_fn_t) (int output_id); typedef int (*orte_gpr_base_module_dump_callbacks_fn_t) (int output_id);
typedef int (*orte_gpr_base_module_dump_notify_msg_fn_t)(orte_gpr_notify_message_t *msg, int output_id); typedef int (*orte_gpr_base_module_dump_notify_msg_fn_t)(orte_gpr_notify_message_t *msg, int output_id);
@ -554,6 +573,7 @@ struct orte_gpr_base_module_1_0_0_t {
/* SUBSCRIBE OPERATIONS */ /* SUBSCRIBE OPERATIONS */
orte_gpr_base_module_subscribe_fn_t subscribe; orte_gpr_base_module_subscribe_fn_t subscribe;
orte_gpr_base_module_unsubscribe_fn_t unsubscribe; orte_gpr_base_module_unsubscribe_fn_t unsubscribe;
orte_gpr_base_module_cancel_trigger_fn_t cancel_trigger;
/* COMPOUND COMMANDS */ /* COMPOUND COMMANDS */
orte_gpr_base_module_begin_compound_cmd_fn_t begin_compound_cmd; orte_gpr_base_module_begin_compound_cmd_fn_t begin_compound_cmd;
orte_gpr_base_module_stop_compound_cmd_fn_t stop_compound_cmd; orte_gpr_base_module_stop_compound_cmd_fn_t stop_compound_cmd;
@ -562,6 +582,7 @@ struct orte_gpr_base_module_1_0_0_t {
orte_gpr_base_module_dump_all_fn_t dump_all; orte_gpr_base_module_dump_all_fn_t dump_all;
orte_gpr_base_module_dump_segments_fn_t dump_segments; orte_gpr_base_module_dump_segments_fn_t dump_segments;
orte_gpr_base_module_dump_triggers_fn_t dump_triggers; 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_callbacks_fn_t dump_callbacks; orte_gpr_base_module_dump_callbacks_fn_t dump_callbacks;
orte_gpr_base_module_dump_notify_msg_fn_t dump_notify_msg; orte_gpr_base_module_dump_notify_msg_fn_t dump_notify_msg;
orte_gpr_base_module_dump_notify_data_fn_t dump_notify_data; orte_gpr_base_module_dump_notify_data_fn_t dump_notify_data;

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

@ -49,59 +49,42 @@ extern "C" {
/** Define the notify actions for the subscription system - can be OR'd /** Define the notify actions for the subscription system - can be OR'd
* to create multiple actions * to create multiple actions
*/ */
#define ORTE_GPR_NOTIFY_NONE (uint16_t)0x0000 /**< No trigger action */ #define ORTE_GPR_NOTIFY_NONE (uint8_t)0x00 /**< No trigger action */
#define ORTE_GPR_NOTIFY_VALUE_CHG_TO (uint16_t)0x0001 /**< Notifies subscriber when value changes to specified value */ #define ORTE_GPR_NOTIFY_VALUE_CHG_TO (uint8_t)0x01 /**< Notifies subscriber when value changes to specified value */
#define ORTE_GPR_NOTIFY_VALUE_CHG_FRM (uint16_t)0x0002 /**< Notifies subscriber when value changes away from specified value */ #define ORTE_GPR_NOTIFY_VALUE_CHG_FRM (uint8_t)0x02 /**< Notifies subscriber when value changes away from specified value */
#define ORTE_GPR_NOTIFY_VALUE_CHG (uint16_t)0x0003 /**< Notifies subscriber when value changes */ #define ORTE_GPR_NOTIFY_VALUE_CHG (uint8_t)0x03 /**< Notifies subscriber when value changes */
#define ORTE_GPR_NOTIFY_ADD_ENTRY (uint16_t)0x0004 /**< Notifies subscriber when entry added */ #define ORTE_GPR_NOTIFY_ADD_ENTRY (uint8_t)0x04 /**< Notifies subscriber when entry added */
#define ORTE_GPR_NOTIFY_DEL_ENTRY (uint16_t)0x0008 /**< Notifies subscriber when entry deleted */ #define ORTE_GPR_NOTIFY_DEL_ENTRY (uint8_t)0x08 /**< Notifies subscriber when entry deleted */
#define ORTE_GPR_NOTIFY_ALL (uint16_t)0x000f /**< Notifies subscriber upon any action */ #define ORTE_GPR_NOTIFY_ALL (uint8_t)0x0f /**< Notifies subscriber upon any action */
#define ORTE_GPR_NOTIFY_PRE_EXISTING (uint16_t)0x0010 /**< Provide list of all pre-existing data */ #define ORTE_GPR_NOTIFY_PRE_EXISTING (uint8_t)0x10 /**< Provide list of all pre-existing data */
#define ORTE_GPR_NOTIFY_ANY (uint16_t)0x00ff /**< Used to test if any action flags set */ #define ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG (uint8_t)0x20 /**< Notifies are off when subscription entered - turned on when trigger fires */
#define ORTE_GPR_NOTIFY_NO_DATA_WITH_TRIG (uint8_t)0x40 /**< Do not include subscription data when initial trigger fires */
#define ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG (uint8_t)0x80
#define ORTE_GPR_NOTIFY_ANY (uint8_t)0xff /**< Used to test if any action flags set */
#define ORTE_GPR_TRIG_ONE_SHOT (uint16_t)0x0100 /**< Only trigger once - then delete subscription */ typedef uint8_t orte_gpr_notify_action_t;
#define ORTE_GPR_TRIG_AT_LEVEL (uint16_t)0x0200 /**< Trigger whenever count reaches specified level */ #define ORTE_GPR_NOTIFY_ACTION_T ORTE_UINT8
#define ORTE_GPR_TRIG_CMP_LEVELS (uint16_t)0x0400 /**< Trigger when all the specified values are equal */
#define ORTE_GPR_TRIG_MONITOR_ONLY (uint16_t)0x0800 /**< Monitor the provided trigger keyval - counting done by someone else */
#define ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG (uint16_t)0x1000 /**< Notifies are off when subscription entered - turned on when trigger fires */
#define ORTE_GPR_TRIG_INCLUDE_DATA (uint16_t)0x2000 /**< Include the trigger data in the trigger msg */
#define ORTE_GPR_TRIG_ALL_AT (uint16_t)0xdb00 /**< Use all trig defs except include trig data with AT - a typical situation */
#define ORTE_GPR_TRIG_ALL_CMP (uint16_t)0xdd00 /**< Use all trig defs except include trig data with CMP */
#define ORTE_GPR_TRIG_ANY (uint16_t)0xff00 /**< Used to test if any trigs are set */
typedef uint16_t orte_gpr_notify_action_t; typedef size_t orte_gpr_subscription_id_t;
#define ORTE_GPR_NOTIFY_ACTION_T ORTE_UINT16 #define ORTE_GPR_SUBSCRIPTION_ID_T DPS_TYPE_SIZE_T
#define ORTE_GPR_SUBSCRIPTION_ID_MAX SIZE_MAX
typedef size_t orte_gpr_notify_id_t;
#define ORTE_GPR_NOTIFY_ID_T DPS_TYPE_SIZE_T
#define ORTE_GPR_NOTIFY_ID_MAX SIZE_MAX
/* #define ORTE_GPR_TRIG_ONE_SHOT (uint8_t)0x01 /**< Only trigger once - then delete subscription */
* Define flag values for remote commands - normally used internally, but required #define ORTE_GPR_TRIG_INCLUDE_DATA (uint8_t)0x02 /**< Include the trigger data in the notification msg */
* here to allow for decoding of notify messages #define ORTE_GPR_TRIG_AT_LEVEL (uint8_t)0x08 /**< Trigger whenever count reaches specified level */
*/ #define ORTE_GPR_TRIG_CMP_LEVELS (uint8_t)0x80 /**< Trigger when all the specified values are equal */
#define ORTE_GPR_DELETE_SEGMENT_CMD (uint16_t)0x0001 #define ORTE_GPR_TRIG_ALL_AT (uint8_t)0x7f /**< Use all trig defs except include trig data with AT - a typical situation */
#define ORTE_GPR_PUT_CMD (uint16_t)0x0002 #define ORTE_GPR_TRIG_ALL_CMP (uint8_t)0xf7 /**< Use all trig defs except include trig data with CMP */
#define ORTE_GPR_DELETE_ENTRIES_CMD (uint16_t)0x0004 #define ORTE_GPR_TRIG_ANY (uint8_t)0xff /**< Used to test if any trigs are set */
#define ORTE_GPR_INDEX_CMD (uint16_t)0x0008
#define ORTE_GPR_SUBSCRIBE_CMD (uint16_t)0x0010 typedef uint8_t orte_gpr_trigger_action_t;
#define ORTE_GPR_UNSUBSCRIBE_CMD (uint16_t)0x0020 #define ORTE_GPR_TRIGGER_ACTION_T ORTE_UINT8
#define ORTE_GPR_GET_CMD (uint16_t)0x0100
#define ORTE_GPR_TEST_INTERNALS_CMD (uint16_t)0x0200 typedef size_t orte_gpr_trigger_id_t;
#define ORTE_GPR_NOTIFY_CMD (uint16_t)0x0400 #define ORTE_GPR_TRIGGER_ID_T DPS_TYPE_SIZE_T
#define ORTE_GPR_DUMP_ALL_CMD (uint16_t)0x0800 #define ORTE_GPR_TRIGGER_ID_MAX SIZE_MAX
#define ORTE_GPR_DUMP_SEGMENTS_CMD (uint16_t)0x0810
#define ORTE_GPR_DUMP_TRIGGERS_CMD (uint16_t)0x0820
#define ORTE_GPR_DUMP_CALLBACKS_CMD (uint16_t)0x0830
#define ORTE_GPR_INCREMENT_VALUE_CMD (uint16_t)0x2000
#define ORTE_GPR_DECREMENT_VALUE_CMD (uint16_t)0x4000
#define ORTE_GPR_COMPOUND_CMD (uint16_t)0x8000
#define ORTE_GPR_CLEANUP_JOB_CMD (uint16_t)0x8200
#define ORTE_GPR_CLEANUP_PROC_CMD (uint16_t)0x8400
#define ORTE_GPR_ERROR (uint16_t)0xffff
typedef uint16_t orte_gpr_cmd_flag_t;
#define ORTE_GPR_CMD_T ORTE_UINT16
/** Define the addressing mode bit-masks for registry operations. /** Define the addressing mode bit-masks for registry operations.
* *
@ -201,12 +184,10 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_gpr_value_t);
* data from a single segment, one or more containers with one or more keyvals/container. * data from a single segment, one or more containers with one or more keyvals/container.
*/ */
typedef struct { typedef struct {
ompi_object_t super; /**< Makes this an object */ ompi_object_t super; /**< Makes this an object */
size_t cb_num; /**< Number of the subscribed data - indicates which callback to use */ orte_gpr_subscription_id_t id; /**< Number of the associated subscription */
orte_gpr_addr_mode_t addr_mode; /**< Address mode that was used for combining keys/tokens */ size_t cnt; /**< Number of value objects returned, one per container */
char *segment; /**< Name of the segment this came from */ orte_gpr_value_t **values; /**< Array of value objects returned */
size_t cnt; /**< Number of value objects returned, one per container */
orte_gpr_value_t **values; /**< Array of value objects returned */
} orte_gpr_notify_data_t; } orte_gpr_notify_data_t;
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_gpr_notify_data_t); OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_gpr_notify_data_t);
@ -215,7 +196,6 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_gpr_notify_data_t);
*/ */
typedef struct { typedef struct {
ompi_object_t super; /**< Make this an object */ ompi_object_t super; /**< Make this an object */
orte_gpr_notify_id_t idtag; /**< Referenced notify request */
size_t cnt; /**< number of data objects */ size_t cnt; /**< number of data objects */
orte_gpr_notify_data_t **data; /**< Contiguous array of pointers to data objects */ orte_gpr_notify_data_t **data; /**< Contiguous array of pointers to data objects */
} orte_gpr_notify_message_t; } orte_gpr_notify_message_t;
@ -240,18 +220,36 @@ typedef void (*orte_gpr_notify_cb_fn_t)(orte_gpr_notify_data_t *notify_data, voi
*/ */
typedef struct { typedef struct {
ompi_object_t super; /**< Makes this an object */ ompi_object_t super; /**< Makes this an object */
orte_gpr_addr_mode_t addr_mode; /**< Address mode for combining keys/tokens */ char *name; /**< A unique name for this subscription - can be NULL */
char *segment; /**< Name of the segment where the data is located */ orte_gpr_subscription_id_t id; /**< id number of this subscription, as assigned by system */
size_t num_tokens; /**< Number of tokens used to describe data */ orte_gpr_notify_action_t action; /**< what causes subscription to fire */
char **tokens; /**< List of tokens that describe the data */ size_t cnt; /**< Number of values included */
size_t num_keys; /**< Number of keys describing data */ orte_gpr_value_t **values; /**< Contiguous array of pointers to value objects
char **keys; /**< Contiguous array of keys */ describing the data to be returned */
orte_gpr_notify_cb_fn_t cbfunc; /**< Function to be called with this data */ orte_gpr_notify_cb_fn_t cbfunc; /**< Function to be called with this data */
void *user_tag; /**< User-provided tag to be used in cbfunc */ void *user_tag; /**< User-provided tag to be used in cbfunc */
} orte_gpr_subscription_t; } orte_gpr_subscription_t;
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_gpr_subscription_t); OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_gpr_subscription_t);
/** Structure for registering triggers
* A trigger causes the associated subscriptions to be executed at a specified event,
* such as when counters reach specified values. The data provided here specifies
* which objects on the registry are to be monitored, and what conditions must
* exist between those objects for the trigger to be "fired".
*/
typedef struct {
ompi_object_t super; /**< Makes this an object */
char *name; /**< A unique name for this trigger - can be NULL */
orte_gpr_trigger_id_t id; /**< id number of this trigger, as assigned by system */
orte_gpr_trigger_action_t action; /**< trigger characteristics */
size_t cnt; /**< Number of values included */
orte_gpr_value_t **values; /**< Contiguous array of pointers to value objects
describing the objects to be monitored */
} orte_gpr_trigger_t;
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_gpr_trigger_t);
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
} }
#endif #endif

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

@ -53,28 +53,19 @@ int orte_gpr_proxy_finalize(void);
* proxy-local types * proxy-local types
*/ */
typedef struct { typedef struct {
ompi_object_t super; /**< Allows this to be an object */ ompi_object_t super; /**< Allows this to be an object */
size_t index; /**< Index of this callback */ orte_gpr_subscription_id_t id; /**< id of this subscription */
orte_gpr_notify_cb_fn_t callback; /**< Function to be called for notificaiton */ orte_gpr_notify_cb_fn_t callback; /**< Function to be called for notificaiton */
void *user_tag; /**< User-provided tag for callback function */ void *user_tag; /**< User-provided tag for callback function */
} orte_gpr_proxy_subscriber_t; } orte_gpr_proxy_subscriber_t;
OBJ_CLASS_DECLARATION(orte_gpr_proxy_subscriber_t); OBJ_CLASS_DECLARATION(orte_gpr_proxy_subscriber_t);
struct orte_gpr_proxy_notify_tracker_t {
ompi_object_t super; /**< Allows this to be an object */
orte_gpr_notify_id_t remote_idtag; /**< Remote ID tag of subscription */
orte_pointer_array_t *callbacks; /**< Array of registered callbacks for this subscription */
};
typedef struct orte_gpr_proxy_notify_tracker_t orte_gpr_proxy_notify_tracker_t;
OBJ_CLASS_DECLARATION(orte_gpr_proxy_notify_tracker_t);
#define ORTE_GPR_PROXY_MAX_SIZE INT32_MAX #define ORTE_GPR_PROXY_MAX_SIZE INT32_MAX
#define ORTE_GPR_PROXY_BLOCK_SIZE 100 #define ORTE_GPR_PROXY_BLOCK_SIZE 100
/* /*
* globals used within proxy component * globals used within proxy component
*/ */
@ -82,7 +73,9 @@ typedef struct {
int debug; int debug;
size_t block_size; size_t block_size;
size_t max_size; size_t max_size;
orte_pointer_array_t *notify_tracker; orte_gpr_subscription_id_t num_subs;
orte_pointer_array_t *subscriptions;
orte_gpr_trigger_id_t trig_cntr;
ompi_mutex_t mutex; ompi_mutex_t mutex;
bool compound_cmd_mode; bool compound_cmd_mode;
orte_buffer_t *compound_cmd; orte_buffer_t *compound_cmd;
@ -160,14 +153,14 @@ int orte_gpr_proxy_get_nb(orte_gpr_addr_mode_t addr_mode,
/* /*
* Subscribe functions * Subscribe functions
*/ */
int orte_gpr_proxy_subscribe(orte_gpr_notify_action_t action, int orte_gpr_proxy_subscribe(size_t num_subs,
size_t num_subs,
orte_gpr_subscription_t **subscriptions, orte_gpr_subscription_t **subscriptions,
size_t num_trigs, size_t num_trigs,
orte_gpr_value_t **trigs, orte_gpr_trigger_t **trigs);
orte_gpr_notify_id_t *sub_number);
int orte_gpr_proxy_unsubscribe(orte_gpr_notify_id_t sub_number); int orte_gpr_proxy_unsubscribe(orte_gpr_subscription_id_t sub_number);
int orte_gpr_proxy_cancel_trigger(orte_gpr_trigger_id_t trig);
/* /*
@ -179,6 +172,8 @@ int orte_gpr_proxy_dump_segments(int output_id);
int orte_gpr_proxy_dump_triggers(int output_id); int orte_gpr_proxy_dump_triggers(int output_id);
int orte_gpr_proxy_dump_subscriptions(int output_id);
int orte_gpr_proxy_dump_callbacks(int output_id); int orte_gpr_proxy_dump_callbacks(int output_id);
int orte_gpr_proxy_dump_notify_msg(orte_gpr_notify_message_t *msg, int output_id); int orte_gpr_proxy_dump_notify_msg(orte_gpr_notify_message_t *msg, int output_id);
@ -205,15 +200,14 @@ void orte_gpr_proxy_notify_recv(int status, orte_process_name_t* sender,
*/ */
int int
orte_gpr_proxy_enter_notify_request(orte_gpr_notify_id_t *local_idtag, orte_gpr_proxy_enter_subscription(size_t cnt, orte_gpr_subscription_t **subscriptions);
size_t cnt, orte_gpr_subscription_t **subscriptions);
int int
orte_gpr_proxy_remove_notify_request(orte_gpr_notify_id_t local_idtag, orte_gpr_proxy_remove_subscription(orte_gpr_subscription_id_t id);
orte_gpr_notify_id_t *remote_idtag);
int
orte_gpr_proxy_enter_trigger(size_t cnt, orte_gpr_trigger_t **triggers);
int orte_gpr_proxy_set_remote_idtag(orte_gpr_notify_id_t local_idtag,
orte_gpr_notify_id_t remote_idtag);
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
} }

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

@ -88,6 +88,7 @@ static orte_gpr_base_module_t orte_gpr_proxy = {
/* SUBSCRIBE OPERATIONS */ /* SUBSCRIBE OPERATIONS */
orte_gpr_proxy_subscribe, orte_gpr_proxy_subscribe,
orte_gpr_proxy_unsubscribe, orte_gpr_proxy_unsubscribe,
orte_gpr_proxy_cancel_trigger,
/* COMPOUND COMMANDS */ /* COMPOUND COMMANDS */
orte_gpr_proxy_begin_compound_cmd, orte_gpr_proxy_begin_compound_cmd,
orte_gpr_proxy_stop_compound_cmd, orte_gpr_proxy_stop_compound_cmd,
@ -96,6 +97,7 @@ static orte_gpr_base_module_t orte_gpr_proxy = {
orte_gpr_proxy_dump_all, orte_gpr_proxy_dump_all,
orte_gpr_proxy_dump_segments, orte_gpr_proxy_dump_segments,
orte_gpr_proxy_dump_triggers, orte_gpr_proxy_dump_triggers,
orte_gpr_proxy_dump_subscriptions,
orte_gpr_proxy_dump_callbacks, orte_gpr_proxy_dump_callbacks,
orte_gpr_proxy_dump_notify_msg, orte_gpr_proxy_dump_notify_msg,
orte_gpr_proxy_dump_notify_data, orte_gpr_proxy_dump_notify_data,
@ -122,7 +124,7 @@ static void orte_gpr_proxy_subscriber_construct(orte_gpr_proxy_subscriber_t* req
{ {
req->callback = NULL; req->callback = NULL;
req->user_tag = NULL; req->user_tag = NULL;
req->index = 0; req->id = 0;
} }
/* destructor - used to free any resources held by instance */ /* destructor - used to free any resources held by instance */
@ -138,31 +140,6 @@ OBJ_CLASS_INSTANCE(
orte_gpr_proxy_subscriber_destructor); /* destructor */ orte_gpr_proxy_subscriber_destructor); /* destructor */
/* NOTIFY TRACKER */
/* constructor - used to initialize notify message instance */
static void orte_gpr_proxy_notify_tracker_construct(orte_gpr_proxy_notify_tracker_t* req)
{
req->remote_idtag = ORTE_GPR_NOTIFY_ID_MAX;
orte_pointer_array_init(&(req->callbacks), orte_gpr_proxy_globals.block_size,
orte_gpr_proxy_globals.max_size,
orte_gpr_proxy_globals.block_size);
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_proxy_notify_tracker_destructor(orte_gpr_proxy_notify_tracker_t* req)
{
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_proxy_notify_tracker_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_proxy_notify_tracker_construct, /* constructor */
orte_gpr_proxy_notify_tracker_destructor); /* destructor */
/* /*
* Open the component * Open the component
*/ */
@ -214,49 +191,53 @@ orte_gpr_proxy_component_init(bool *allow_multi_user_threads, bool *have_hidden_
the setup and return the module */ the setup and return the module */
if (NULL != orte_process_info.gpr_replica_uri) { if (NULL != orte_process_info.gpr_replica_uri) {
if (orte_gpr_proxy_globals.debug) { if (orte_gpr_proxy_globals.debug) {
ompi_output(0, "gpr_proxy_init: proxy selected"); ompi_output(0, "gpr_proxy_init: proxy selected");
} }
/* setup the replica location */
if(ORTE_SUCCESS != (ret = orte_rml.parse_uris(orte_process_info.gpr_replica_uri, &name, NULL))) {
ORTE_ERROR_LOG(ret);
return NULL;
}
if(ORTE_SUCCESS != (ret = orte_ns.copy_process_name(&orte_process_info.gpr_replica, &name))) {
ORTE_ERROR_LOG(ret);
return NULL;
}
/* Return a module (choose an arbitrary, positive priority -- /* setup the replica location */
it's only relevant compared to other ns components). If if(ORTE_SUCCESS != (ret = orte_rml.parse_uris(orte_process_info.gpr_replica_uri, &name, NULL))) {
we're not the seed, then we don't want to be selected, so ORTE_ERROR_LOG(ret);
return NULL. */ return NULL;
}
*priority = 10; if(ORTE_SUCCESS != (ret = orte_ns.copy_process_name(&orte_process_info.gpr_replica, &name))) {
ORTE_ERROR_LOG(ret);
/* We allow multi user threads but don't have any hidden threads */ return NULL;
}
*allow_multi_user_threads = true;
*have_hidden_threads = false; /* Return a module (choose an arbitrary, positive priority --
it's only relevant compared to other ns components). If
/* setup thread locks and condition variable */ we're not the seed, then we don't want to be selected, so
OBJ_CONSTRUCT(&orte_gpr_proxy_globals.mutex, ompi_mutex_t); return NULL. */
OBJ_CONSTRUCT(&orte_gpr_proxy_globals.wait_for_compound_mutex, ompi_mutex_t);
OBJ_CONSTRUCT(&orte_gpr_proxy_globals.compound_cmd_condition, ompi_condition_t); *priority = 10;
/* initialize the registry compound mode */ /* We allow multi user threads but don't have any hidden threads */
orte_gpr_proxy_globals.compound_cmd_mode = false;
orte_gpr_proxy_globals.compound_cmd_waiting = 0; *allow_multi_user_threads = true;
orte_gpr_proxy_globals.compound_cmd = NULL; *have_hidden_threads = false;
/* initialize the notify request tracker */ /* setup thread locks and condition variable */
if (ORTE_SUCCESS != orte_pointer_array_init(&(orte_gpr_proxy_globals.notify_tracker), OBJ_CONSTRUCT(&orte_gpr_proxy_globals.mutex, ompi_mutex_t);
OBJ_CONSTRUCT(&orte_gpr_proxy_globals.wait_for_compound_mutex, ompi_mutex_t);
OBJ_CONSTRUCT(&orte_gpr_proxy_globals.compound_cmd_condition, ompi_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 != orte_pointer_array_init(&(orte_gpr_proxy_globals.subscriptions),
orte_gpr_proxy_globals.block_size, orte_gpr_proxy_globals.block_size,
orte_gpr_proxy_globals.max_size, orte_gpr_proxy_globals.max_size,
orte_gpr_proxy_globals.block_size)) { orte_gpr_proxy_globals.block_size)) {
return NULL; return NULL;
} }
/* initialize the trigger counter */
orte_gpr_proxy_globals.trig_cntr = 0;
initialized = true; initialized = true;
return &orte_gpr_proxy; return &orte_gpr_proxy;
} else { } else {
@ -305,13 +286,11 @@ void orte_gpr_proxy_notify_recv(int status, orte_process_name_t* sender,
void* cbdata) void* cbdata)
{ {
orte_gpr_cmd_flag_t command; orte_gpr_cmd_flag_t command;
orte_gpr_notify_id_t id_tag;
orte_gpr_notify_data_t **data; orte_gpr_notify_data_t **data;
orte_gpr_proxy_notify_tracker_t *trackptr; orte_gpr_proxy_subscriber_t *sub;
orte_gpr_proxy_subscriber_t **subs;
size_t n; size_t n;
int rc; int rc;
size_t num_msgs, cnt, i, j, k; size_t cnt, i;
if (orte_gpr_proxy_globals.debug) { if (orte_gpr_proxy_globals.debug) {
ompi_output(0, "[%lu,%lu,%lu] gpr proxy: received trigger message", ompi_output(0, "[%lu,%lu,%lu] gpr proxy: received trigger message",
@ -330,60 +309,46 @@ void orte_gpr_proxy_notify_recv(int status, orte_process_name_t* sender,
} }
n = 1; n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &num_msgs, &n, ORTE_SIZE))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &cnt, &n, ORTE_SIZE))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
goto RETURN_ERROR; goto RETURN_ERROR;
} }
for (k=0; k < num_msgs; k++) { if (cnt > 0) {
n = 1; /* allocate space for the array */
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &id_tag, &n, ORTE_GPR_NOTIFY_ID))) { data = (orte_gpr_notify_data_t**)malloc(cnt * sizeof(orte_gpr_notify_data_t*));
ORTE_ERROR_LOG(rc); if (NULL == data) {
goto RETURN_ERROR; ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
}
/* locate request corresponding to this message */
trackptr = (orte_gpr_proxy_notify_tracker_t*)((orte_gpr_proxy_globals.notify_tracker)->addr[id_tag]);
if (NULL == trackptr) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
goto RETURN_ERROR; goto RETURN_ERROR;
} }
n = 1; if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, data, &cnt, ORTE_GPR_NOTIFY_DATA))) {
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &cnt, &n, ORTE_SIZE))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
goto RETURN_ERROR; goto RETURN_ERROR;
} }
if(cnt > 0) {
/* allocate space for the array */ for (i=0; i < cnt; i++) {
data = (orte_gpr_notify_data_t**)malloc(cnt * sizeof(orte_gpr_notify_data_t*)); /* process request */
if (NULL == data) { if (data[i]->id > orte_gpr_proxy_globals.num_subs) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_GPR_DATA_CORRUPT);
goto RETURN_ERROR; OBJ_RELEASE(data[i]);
} continue;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, data, &cnt, ORTE_GPR_NOTIFY_DATA))) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
for (i=0; i < cnt; i++) {
/* locate the data callback */
subs = (orte_gpr_proxy_subscriber_t**)((trackptr->callbacks)->addr);
for (j=0; j < (trackptr->callbacks)->size; j++) {
if (NULL != subs[j] && subs[j]->index == data[i]->cb_num) {
/* process request */
subs[j]->callback(data[i], subs[j]->user_tag);
break;
}
}
} }
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);
}
OBJ_RELEASE(data[i]);
} }
/* release data */
free(data);
} }
RETURN_ERROR: RETURN_ERROR:
/* reissue non-blocking receive */ /* reissue non-blocking receive */
orte_rml.recv_buffer_nb(ORTE_RML_NAME_ANY, ORTE_RML_TAG_GPR_NOTIFY, 0, orte_gpr_proxy_notify_recv, NULL); orte_rml.recv_buffer_nb(ORTE_RML_NAME_ANY, ORTE_RML_TAG_GPR_NOTIFY, 0, orte_gpr_proxy_notify_recv, NULL);

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

@ -228,6 +228,67 @@ int orte_gpr_proxy_dump_triggers(int output_id)
return rc; return rc;
} }
int orte_gpr_proxy_dump_subscriptions(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_subscriptions(orte_gpr_proxy_globals.compound_cmd);
}
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_subscriptions(cmd))) {
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_SUBSCRIPTIONS_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) int orte_gpr_proxy_dump_callbacks(int output_id)
{ {
orte_gpr_cmd_flag_t command; orte_gpr_cmd_flag_t command;

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

@ -37,47 +37,26 @@
#include "gpr_proxy.h" #include "gpr_proxy.h"
int int
orte_gpr_proxy_enter_notify_request(orte_gpr_notify_id_t *local_idtag, orte_gpr_proxy_enter_subscription(size_t cnt, orte_gpr_subscription_t **subscriptions)
size_t cnt, orte_gpr_subscription_t **subscriptions)
{ {
orte_gpr_proxy_notify_tracker_t *trackptr;
orte_gpr_proxy_subscriber_t *sub; orte_gpr_proxy_subscriber_t *sub;
size_t idtag, i; size_t i, id;
*local_idtag = ORTE_GPR_NOTIFY_ID_MAX;
trackptr = OBJ_NEW(orte_gpr_proxy_notify_tracker_t);
if (NULL == trackptr) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trackptr->remote_idtag = ORTE_GPR_NOTIFY_ID_MAX;
for (i=0; i < cnt; i++) { for (i=0; i < cnt; i++) {
sub = OBJ_NEW(orte_gpr_proxy_subscriber_t); sub = OBJ_NEW(orte_gpr_proxy_subscriber_t);
if (NULL == sub) { if (NULL == sub) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
sub->index = i;
sub->callback = subscriptions[i]->cbfunc; sub->callback = subscriptions[i]->cbfunc;
sub->user_tag = subscriptions[i]->user_tag; sub->user_tag = subscriptions[i]->user_tag;
if (0 > orte_pointer_array_add(&idtag, trackptr->callbacks, sub)) { if (0 > orte_pointer_array_add(&id, orte_gpr_proxy_globals.subscriptions, sub)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
} sub->id = (orte_gpr_subscription_id_t)id;
subscriptions[i]->id = sub->id;
if (0 > orte_pointer_array_add(&idtag, orte_gpr_proxy_globals.notify_tracker, trackptr)) { (orte_gpr_proxy_globals.num_subs)++;
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
*local_idtag = idtag;
if (orte_gpr_proxy_globals.debug) {
ompi_output(0, "[%lu,%lu,%lu] enter_notify_request: tracker %d created",
ORTE_NAME_ARGS(orte_process_info.my_name), idtag);
} }
return ORTE_SUCCESS; return ORTE_SUCCESS;
@ -85,32 +64,32 @@ orte_gpr_proxy_enter_notify_request(orte_gpr_notify_id_t *local_idtag,
int int
orte_gpr_proxy_remove_notify_request(orte_gpr_notify_id_t local_idtag, orte_gpr_proxy_enter_trigger(size_t cnt, orte_gpr_trigger_t **trigs)
orte_gpr_notify_id_t *remote_idtag)
{ {
orte_gpr_proxy_notify_tracker_t *trackptr; size_t i;
trackptr = (orte_gpr_proxy_notify_tracker_t*)((orte_gpr_proxy_globals.notify_tracker)->addr[local_idtag]); for (i=0; i < cnt; i++) {
if (NULL == trackptr) { if (ORTE_GPR_TRIGGER_ID_MAX-1 > orte_gpr_proxy_globals.trig_cntr) {
return ORTE_ERR_BAD_PARAM; trigs[i]->id = orte_gpr_proxy_globals.trig_cntr;
(orte_gpr_proxy_globals.trig_cntr)++;
} else {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
} }
*remote_idtag = trackptr->remote_idtag;
OBJ_RELEASE(trackptr);
orte_pointer_array_set_item(orte_gpr_proxy_globals.notify_tracker, local_idtag, NULL);
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
int orte_gpr_proxy_set_remote_idtag(orte_gpr_notify_id_t local_idtag, orte_gpr_notify_id_t remote_idtag) int
orte_gpr_proxy_remove_subscription(orte_gpr_subscription_id_t id)
{ {
orte_gpr_proxy_notify_tracker_t *trackptr; if (NULL != (orte_gpr_proxy_globals.subscriptions)->addr[id]) {
OBJ_RELEASE((orte_gpr_proxy_globals.subscriptions)->addr[id]);
trackptr = (orte_gpr_proxy_notify_tracker_t*)((orte_gpr_proxy_globals.notify_tracker)->addr[local_idtag]); orte_pointer_array_set_item(orte_gpr_proxy_globals.subscriptions, (size_t)id, NULL);
if (NULL == trackptr) {
return ORTE_ERR_BAD_PARAM;
} }
trackptr->remote_idtag = remote_idtag;
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }

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

@ -38,176 +38,160 @@
#include "gpr_proxy.h" #include "gpr_proxy.h"
int int
orte_gpr_proxy_subscribe(orte_gpr_notify_action_t action, orte_gpr_proxy_subscribe(size_t num_subs,
size_t num_subs,
orte_gpr_subscription_t **subscriptions, orte_gpr_subscription_t **subscriptions,
size_t num_trigs, size_t num_trigs,
orte_gpr_value_t **trigs, orte_gpr_trigger_t **trigs)
orte_gpr_notify_id_t *sub_number)
{ {
orte_buffer_t *cmd; orte_buffer_t *cmd;
orte_buffer_t *answer; orte_buffer_t *answer;
int rc = ORTE_SUCCESS, ret; int rc = ORTE_SUCCESS, ret;
orte_gpr_notify_id_t idtag, remote_idtag; size_t i;
*sub_number = ORTE_GPR_NOTIFY_ID_MAX;
/* need to protect against errors */ /* need to protect against errors */
if (NULL == subscriptions) { if (NULL == subscriptions) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM; return ORTE_ERR_BAD_PARAM;
} }
/* if this has a trigger in it, must specify the trigger condition */ OMPI_THREAD_LOCK(&orte_gpr_proxy_globals.mutex);
if (ORTE_GPR_TRIG_ANY & action && NULL == trigs) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); /* store callback function and user_tag in local list for lookup
return ORTE_ERR_BAD_PARAM; * generate id_tag to send to replica to identify lookup entry
* for each subscription
*/
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_enter_subscription(
num_subs, subscriptions))) {
ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
} }
/* if any triggers were provided, get id tags for them */
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_enter_trigger(
num_trigs, trigs))) {
ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
}
/* check for compound cmd mode - if on, just pack the info into the
* compound cmd buffer and return
*/
if (orte_gpr_proxy_globals.compound_cmd_mode) { if (orte_gpr_proxy_globals.compound_cmd_mode) {
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_subscribe(orte_gpr_proxy_globals.compound_cmd, if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_subscribe(orte_gpr_proxy_globals.compound_cmd,
action, num_subs, subscriptions, num_subs, subscriptions,
num_trigs, trigs))) { num_trigs, trigs))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; goto ERROR;
} }
OMPI_THREAD_LOCK(&orte_gpr_proxy_globals.mutex);
/* store callback function and user_tag in local list for lookup */
/* generate id_tag to send to replica to identify lookup entry */
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_enter_notify_request(&idtag,
num_subs, subscriptions))) {
ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
}
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
if (ORTE_SUCCESS != (rc = orte_dps.pack(orte_gpr_proxy_globals.compound_cmd,
&idtag, 1, ORTE_GPR_NOTIFY_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* done */ /* done */
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
/* if compound cmd not on, get new buffer to transmit command to replica */
cmd = OBJ_NEW(orte_buffer_t); cmd = OBJ_NEW(orte_buffer_t);
if (NULL == cmd) { if (NULL == cmd) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; rc = ORTE_ERR_OUT_OF_RESOURCE;
goto ERROR;
} }
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_subscribe(cmd, action, /* pack the command and send it */
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_subscribe(cmd,
num_subs, subscriptions, num_subs, subscriptions,
num_trigs, trigs))) { num_trigs, trigs))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_RELEASE(cmd); OBJ_RELEASE(cmd);
return rc; goto ERROR;
} }
OMPI_THREAD_LOCK(&orte_gpr_proxy_globals.mutex);
/* store callback function and user_tag in local list for lookup */
/* generate id_tag to send to replica to identify lookup entry */
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_enter_notify_request(&idtag,
num_subs, subscriptions))) {
ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
OBJ_RELEASE(cmd);
return rc;
}
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &idtag, 1, ORTE_GPR_NOTIFY_ID))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(cmd);
return rc;
}
if (orte_gpr_proxy_globals.debug) {
ompi_output(0, "[%lu,%lu,%lu] gpr proxy subscribe: register subscribe for local idtag %d",
ORTE_NAME_ARGS(orte_process_info.my_name), (int)idtag);
}
if (0 > orte_rml.send_buffer(orte_process_info.gpr_replica, cmd, ORTE_RML_TAG_GPR, 0)) { if (0 > orte_rml.send_buffer(orte_process_info.gpr_replica, cmd, ORTE_RML_TAG_GPR, 0)) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
OMPI_THREAD_LOCK(&orte_gpr_proxy_globals.mutex); OBJ_RELEASE(cmd);
orte_gpr_proxy_remove_notify_request(idtag, &remote_idtag); rc = ORTE_ERR_COMM_FAILURE;
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex); goto ERROR;
return ORTE_ERR_COMM_FAILURE;
} }
OBJ_RELEASE(cmd);
/* get buffer for reply from replica and get it */
answer = OBJ_NEW(orte_buffer_t); answer = OBJ_NEW(orte_buffer_t);
if (NULL == answer) { if (NULL == answer) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OMPI_THREAD_LOCK(&orte_gpr_proxy_globals.mutex); rc = ORTE_ERR_OUT_OF_RESOURCE;
orte_gpr_proxy_remove_notify_request(idtag, &remote_idtag); goto ERROR;
OMPI_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)) { if (0 > orte_rml.recv_buffer(orte_process_info.gpr_replica, answer, ORTE_RML_TAG_GPR)) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
OMPI_THREAD_LOCK(&orte_gpr_proxy_globals.mutex); OBJ_RELEASE(answer);
orte_gpr_proxy_remove_notify_request(idtag, &remote_idtag); rc = ORTE_ERR_COMM_FAILURE;
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex); goto ERROR;
OBJ_RELEASE(answer);
return ORTE_ERR_COMM_FAILURE;
} }
if (ORTE_SUCCESS != (rc = orte_gpr_base_unpack_subscribe(answer, &ret, &remote_idtag))) { /* unpack the reply - should contain an echo of the subscribe command
* (to ensure the handshake) and the status code of the request. The
* unpack function checks the command for us - will return an error
* if the command was wrong - so all we have to do is record an
* error if the unpack command doesn't return "success", and return
* the resulting status code
*/
if (ORTE_SUCCESS != (rc = orte_gpr_base_unpack_subscribe(answer, &ret))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OMPI_THREAD_LOCK(&orte_gpr_proxy_globals.mutex); OBJ_RELEASE(answer);
orte_gpr_proxy_remove_notify_request(idtag, &remote_idtag); goto ERROR;
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
} }
/* set the remote id tag field */ OBJ_RELEASE(answer);
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_set_remote_idtag(idtag, remote_idtag))) { OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
ORTE_ERROR_LOG(rc); return ORTE_SUCCESS;
OMPI_THREAD_LOCK(&orte_gpr_proxy_globals.mutex);
orte_gpr_proxy_remove_notify_request(idtag, &remote_idtag); /* if an error was encountered during processing this request, we need to
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex); * remove the subscriptions from the subscription tracking system. do this
return rc; * and then exit.
} * NOTE: there is no corresponding function to remove triggers from the local
* trigger tracking system as nothing is stored on it - we just keep track
*sub_number = idtag; * of how many triggers were generated so we can identify them, and the
return ret; * numbers are NOT re-used.
} */
ERROR:
for (i=0; i < num_subs; i++) {
int orte_gpr_proxy_unsubscribe(orte_gpr_notify_id_t sub_number) if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_subscription(subscriptions[i]->id))) {
{
orte_buffer_t *cmd;
orte_buffer_t *answer;
int rc, ret;
orte_gpr_notify_id_t remote_idtag;
if (orte_gpr_proxy_globals.compound_cmd_mode) {
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_unsubscribe(orte_gpr_proxy_globals.compound_cmd,
sub_number))) {
ORTE_ERROR_LOG(rc);
return rc;
}
OMPI_THREAD_LOCK(&orte_gpr_proxy_globals.mutex);
/* remove the notify tag */
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_notify_request(sub_number, &remote_idtag))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex); OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc; return rc;
} }
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(orte_gpr_proxy_globals.compound_cmd,
&remote_idtag, 1, ORTE_GPR_NOTIFY_ID))) { OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
}
int orte_gpr_proxy_unsubscribe(orte_gpr_subscription_id_t sub_number)
{
orte_buffer_t *cmd;
orte_buffer_t *answer;
int rc, ret;
OMPI_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);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
}
/* if in compound cmd mode, then just pack the command into
* that buffer and return
*/
if (orte_gpr_proxy_globals.compound_cmd_mode) {
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_unsubscribe(orte_gpr_proxy_globals.compound_cmd,
sub_number))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
} }
@ -215,53 +199,143 @@ int orte_gpr_proxy_unsubscribe(orte_gpr_notify_id_t sub_number)
return rc; return rc;
} }
/* if not in compound cmd mode, then init a new buffer to
* transmit the command
*/
cmd = OBJ_NEW(orte_buffer_t); cmd = OBJ_NEW(orte_buffer_t);
if (NULL == cmd) { if (NULL == cmd) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
OMPI_THREAD_LOCK(&orte_gpr_proxy_globals.mutex); /* pack and transmit the command */
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_notify_request(sub_number, &remote_idtag))) { if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_unsubscribe(cmd, sub_number))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_RELEASE(cmd); OBJ_RELEASE(cmd);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex); OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc; return rc;
} }
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_unsubscribe(cmd, remote_idtag))) {
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)) { if (0 > orte_rml.send_buffer(orte_process_info.gpr_replica, cmd, ORTE_RML_TAG_GPR, 0)) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
OBJ_RELEASE(cmd); OBJ_RELEASE(cmd);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ORTE_ERR_COMM_FAILURE; return ORTE_ERR_COMM_FAILURE;
} }
OBJ_RELEASE(cmd); OBJ_RELEASE(cmd);
/* init a buffer to receive the replica's reply */
answer = OBJ_NEW(orte_buffer_t); answer = OBJ_NEW(orte_buffer_t);
if (NULL == answer) { if (NULL == answer) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return 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)) { if (0 > orte_rml.recv_buffer(orte_process_info.gpr_replica, answer, ORTE_RML_TAG_GPR)) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
OBJ_RELEASE(answer); OBJ_RELEASE(answer);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ORTE_ERR_COMM_FAILURE; return ORTE_ERR_COMM_FAILURE;
} }
/* unpack the response. This function will automatically check to ensure
* that the command in the response matches the unsubscribe command, thus
* verifying the handshake. If the function returns "success", then the
* commands match and the buffer could be unpacked - all we need do, then
* is return the replica's response code
*/
if (ORTE_SUCCESS != (rc = orte_gpr_base_unpack_unsubscribe(answer, &ret))) { if (ORTE_SUCCESS != (rc = orte_gpr_base_unpack_unsubscribe(answer, &ret))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_RELEASE(answer); OBJ_RELEASE(answer);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc; return rc;
} }
OBJ_RELEASE(answer); OBJ_RELEASE(answer);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ret; return ret;
} }
int orte_gpr_proxy_cancel_trigger(orte_gpr_trigger_id_t trig)
{
orte_buffer_t *cmd;
orte_buffer_t *answer;
int rc, ret;
OMPI_THREAD_LOCK(&orte_gpr_proxy_globals.mutex);
/* if the compound cmd mode is on, pack the command into that buffer
* and return
*/
if (orte_gpr_proxy_globals.compound_cmd_mode) {
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_cancel_trigger(
orte_gpr_proxy_globals.compound_cmd, trig))) {
ORTE_ERROR_LOG(rc);
}
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
}
/* if compound cmd mode is off, init a new buffer for transmitting the
* command to the replica
*/
cmd = OBJ_NEW(orte_buffer_t);
if (NULL == cmd) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OMPI_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);
OBJ_RELEASE(cmd);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
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);
OBJ_RELEASE(cmd);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
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) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OMPI_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);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ORTE_ERR_COMM_FAILURE;
}
/* unpack the response. This function will automatically check to ensure
* that the command in the response matches the cancel_trigger command, thus
* verifying the handshake. If the function returns "success", then the
* commands match and the buffer could be unpacked - all we need do, then
* is return the replica's response code
*/
if (ORTE_SUCCESS != (rc = orte_gpr_base_unpack_unsubscribe(answer, &ret))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(answer);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
}
OBJ_RELEASE(answer);
OMPI_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ret;
}

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

@ -35,6 +35,7 @@ endif
mcacomponentdir = $(libdir)/openmpi mcacomponentdir = $(libdir)/openmpi
mcacomponent_LTLIBRARIES = $(component_install) mcacomponent_LTLIBRARIES = $(component_install)
mca_gpr_replica_la_SOURCES = gpr_replica.h \ mca_gpr_replica_la_SOURCES = gpr_replica.h \
gpr_replica_class_instances.h \
gpr_replica_component.c gpr_replica_component.c
mca_gpr_replica_la_LIBADD = \ mca_gpr_replica_la_LIBADD = \
@ -46,6 +47,7 @@ mca_gpr_replica_la_LDFLAGS = -module -avoid-version
noinst_LTLIBRARIES = $(component_noinst) noinst_LTLIBRARIES = $(component_noinst)
libmca_gpr_replica_la_SOURCES = gpr_replica.h \ libmca_gpr_replica_la_SOURCES = gpr_replica.h \
gpr_replica_class_instances.h \
gpr_replica_component.c gpr_replica_component.c
libmca_gpr_replica_la_LIBADD = \ libmca_gpr_replica_la_LIBADD = \
api_layer/libmca_gpr_replica_api.la \ api_layer/libmca_gpr_replica_api.la \

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

@ -113,15 +113,14 @@ int orte_gpr_replica_get_nb(orte_gpr_addr_mode_t addr_mode,
/* /*
* Subscribe functions * Subscribe functions
*/ */
int orte_gpr_replica_subscribe(orte_gpr_notify_action_t action, int orte_gpr_replica_subscribe(size_t num_subs,
size_t num_subs,
orte_gpr_subscription_t **subscriptions, orte_gpr_subscription_t **subscriptions,
size_t num_trigs, size_t num_trigs,
orte_gpr_value_t **trigs, orte_gpr_trigger_t **trigs);
orte_gpr_notify_id_t *sub_number);
int orte_gpr_replica_unsubscribe(orte_gpr_notify_id_t sub_number); int orte_gpr_replica_unsubscribe(orte_gpr_subscription_id_t sub_number);
int orte_gpr_replica_cancel_trigger(orte_gpr_trigger_id_t trig);
/* /*
* Diagnostic functions * Diagnostic functions
@ -132,6 +131,8 @@ int orte_gpr_replica_dump_segments(int output_id);
int orte_gpr_replica_dump_triggers(int output_id); int orte_gpr_replica_dump_triggers(int output_id);
int orte_gpr_replica_dump_subscriptions(int output_id);
int orte_gpr_replica_dump_callbacks(int output_id); int orte_gpr_replica_dump_callbacks(int output_id);
int orte_gpr_replica_dump_notify_msg(orte_gpr_notify_message_t *msg, int output_id); int orte_gpr_replica_dump_notify_msg(orte_gpr_notify_message_t *msg, int output_id);

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

@ -44,14 +44,6 @@ int orte_gpr_replica_increment_value(orte_gpr_value_t *value)
return ORTE_ERR_BAD_PARAM; return ORTE_ERR_BAD_PARAM;
} }
if (orte_gpr_replica_globals.compound_cmd_mode) {
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_increment_value(
orte_gpr_replica_globals.compound_cmd, value))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
/* find the segment */ /* find the segment */
@ -81,14 +73,12 @@ int orte_gpr_replica_increment_value(orte_gpr_value_t *value)
if (ORTE_SUCCESS == rc) { if (ORTE_SUCCESS == rc) {
if (ORTE_SUCCESS != if (ORTE_SUCCESS !=
(rc = orte_gpr_replica_check_subscriptions(seg))) { (rc = orte_gpr_replica_check_events())) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc; return rc;
} }
if (!orte_gpr_replica.processing_callbacks) { rc = orte_gpr_replica_process_callbacks();
rc = orte_gpr_replica_process_callbacks();
}
} }
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
@ -108,14 +98,6 @@ int orte_gpr_replica_decrement_value(orte_gpr_value_t *value)
return ORTE_ERR_BAD_PARAM; return ORTE_ERR_BAD_PARAM;
} }
if (orte_gpr_replica_globals.compound_cmd_mode) {
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_decrement_value(
orte_gpr_replica_globals.compound_cmd, value))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
/* find the segment */ /* find the segment */
@ -145,14 +127,12 @@ int orte_gpr_replica_decrement_value(orte_gpr_value_t *value)
if (ORTE_SUCCESS == rc) { if (ORTE_SUCCESS == rc) {
if (ORTE_SUCCESS != if (ORTE_SUCCESS !=
(rc = orte_gpr_replica_check_subscriptions(seg))) { (rc = orte_gpr_replica_check_events())) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc; return rc;
} }
if (!orte_gpr_replica.processing_callbacks) { rc = orte_gpr_replica_process_callbacks();
rc = orte_gpr_replica_process_callbacks();
}
} }
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);

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

@ -46,6 +46,12 @@ int orte_gpr_replica_cleanup_job(orte_jobid_t jobid)
return rc; return rc;
} }
if (ORTE_SUCCESS != (rc = orte_gpr_replica_check_events())) {
ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
rc = orte_gpr_replica_process_callbacks(); rc = orte_gpr_replica_process_callbacks();
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
@ -67,6 +73,12 @@ int orte_gpr_replica_cleanup_proc(orte_process_name_t *proc)
return rc; return rc;
} }
if (ORTE_SUCCESS != (rc = orte_gpr_replica_check_events())) {
ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
rc = orte_gpr_replica_process_callbacks(); rc = orte_gpr_replica_process_callbacks();
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);

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

@ -25,109 +25,25 @@
#include "orte_config.h" #include "orte_config.h"
#include "dps/dps.h"
#include "util/output.h"
#include "util/proc_info.h"
#include "mca/ns/ns_types.h"
#include "mca/errmgr/errmgr.h"
#include "mca/gpr/replica/gpr_replica.h"
#include "mca/gpr/replica/communications/gpr_replica_comm.h"
#include "gpr_replica_api.h" #include "gpr_replica_api.h"
/* COMPOUND COMMANDS ARE NOT USED ON THE REPLICA
* Any process co-located with the replica will "drive" the registry
* directly
*/
int orte_gpr_replica_begin_compound_cmd(void) int orte_gpr_replica_begin_compound_cmd(void)
{ {
orte_gpr_cmd_flag_t command;
int rc;
command = ORTE_GPR_COMPOUND_CMD;
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.wait_for_compound_mutex);
while (orte_gpr_replica_globals.compound_cmd_mode) {
orte_gpr_replica_globals.compound_cmd_waiting++;
ompi_condition_wait(&orte_gpr_replica_globals.compound_cmd_condition,
&orte_gpr_replica_globals.wait_for_compound_mutex);
orte_gpr_replica_globals.compound_cmd_waiting--;
}
orte_gpr_replica_globals.compound_cmd_mode = true;
if (NULL != orte_gpr_replica_globals.compound_cmd) {
OBJ_RELEASE(orte_gpr_replica_globals.compound_cmd);
}
orte_gpr_replica_globals.compound_cmd = OBJ_NEW(orte_buffer_t);
if (NULL == orte_gpr_replica_globals.compound_cmd) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
orte_gpr_replica_globals.compound_cmd_mode = false;
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(orte_gpr_replica_globals.compound_cmd, &command,
1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
orte_gpr_replica_globals.compound_cmd_mode = false;
OBJ_RELEASE(orte_gpr_replica_globals.compound_cmd);
return rc;
}
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.wait_for_compound_mutex);
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
int orte_gpr_replica_stop_compound_cmd(void) int orte_gpr_replica_stop_compound_cmd(void)
{ {
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.wait_for_compound_mutex);
orte_gpr_replica_globals.compound_cmd_mode = false;
if (NULL != orte_gpr_replica_globals.compound_cmd) {
OBJ_RELEASE(orte_gpr_replica_globals.compound_cmd);
}
if (orte_gpr_replica_globals.compound_cmd_waiting) {
ompi_condition_signal(&orte_gpr_replica_globals.compound_cmd_condition);
}
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.wait_for_compound_mutex);
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
int orte_gpr_replica_exec_compound_cmd(void) int orte_gpr_replica_exec_compound_cmd(void)
{ {
int rc; return ORTE_SUCCESS;
orte_buffer_t *answer;
if (orte_gpr_replica_globals.debug) {
ompi_output(0, "[%lu,%lu,%lu] Executing compound command",
ORTE_NAME_ARGS(orte_process_info.my_name));
}
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.wait_for_compound_mutex);
if (ORTE_SUCCESS != (rc = orte_gpr_replica_process_command_buffer(orte_gpr_replica_globals.compound_cmd,
NULL, &answer))) {
ORTE_ERROR_LOG(rc);
}
orte_gpr_replica_globals.compound_cmd_mode = false;
if (NULL != orte_gpr_replica_globals.compound_cmd) { /* shouldn't be any way this could be true, but just to be safe... */
OBJ_RELEASE(orte_gpr_replica_globals.compound_cmd);
}
if (orte_gpr_replica_globals.compound_cmd_waiting) {
ompi_condition_signal(&orte_gpr_replica_globals.compound_cmd_condition);
}
if (ORTE_SUCCESS == rc && !orte_gpr_replica.processing_callbacks) {
rc = orte_gpr_replica_process_callbacks();
}
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.wait_for_compound_mutex);
return rc;
} }

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

@ -43,10 +43,6 @@ int orte_gpr_replica_delete_segment(char *segment)
return ORTE_ERROR; return ORTE_ERROR;
} }
if (orte_gpr_replica_globals.compound_cmd_mode) {
return orte_gpr_base_pack_delete_segment(orte_gpr_replica_globals.compound_cmd, segment);
}
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
/* locate the segment */ /* locate the segment */
@ -83,14 +79,6 @@ int orte_gpr_replica_delete_entries(orte_gpr_addr_mode_t addr_mode,
return ORTE_ERROR; return ORTE_ERROR;
} }
if (orte_gpr_replica_globals.compound_cmd_mode) {
rc = orte_gpr_base_pack_delete_entries(orte_gpr_replica_globals.compound_cmd,
addr_mode, segment, tokens, keys);
if (ORTE_SUCCESS != rc)
ORTE_ERROR_LOG(rc);
return rc;
}
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
/* locate the segment */ /* locate the segment */
@ -114,7 +102,7 @@ int orte_gpr_replica_delete_entries(orte_gpr_addr_mode_t addr_mode,
key_itags, num_keys); key_itags, num_keys);
if (ORTE_SUCCESS == rc) { if (ORTE_SUCCESS == rc) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_check_subscriptions(seg))) { if (ORTE_SUCCESS != (rc = orte_gpr_replica_check_events())) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
} }
} }
@ -127,7 +115,7 @@ int orte_gpr_replica_delete_entries(orte_gpr_addr_mode_t addr_mode,
free(key_itags); free(key_itags);
} }
if (ORTE_SUCCESS == rc && !orte_gpr_replica.processing_callbacks) { if (ORTE_SUCCESS == rc) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_process_callbacks())) { if (ORTE_SUCCESS != (rc = orte_gpr_replica_process_callbacks())) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
} }
@ -153,11 +141,6 @@ int orte_gpr_replica_index(char *segment, size_t *cnt, char **index)
orte_gpr_replica_segment_t *seg=NULL; orte_gpr_replica_segment_t *seg=NULL;
int rc; int rc;
if (orte_gpr_replica_globals.compound_cmd_mode) {
rc = orte_gpr_base_pack_index(orte_gpr_replica_globals.compound_cmd, segment);
return rc;
}
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
if (NULL == segment) { /* want global level index */ if (NULL == segment) { /* want global level index */

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

@ -46,14 +46,6 @@ int orte_gpr_replica_dump_all(int output_id)
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
if (orte_gpr_replica_globals.compound_cmd_mode) {
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_dump_all(orte_gpr_replica_globals.compound_cmd))) {
ORTE_ERROR_LOG(rc);
}
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
buffer = OBJ_NEW(orte_buffer_t); buffer = OBJ_NEW(orte_buffer_t);
if (NULL == buffer) { if (NULL == buffer) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
@ -86,14 +78,6 @@ int orte_gpr_replica_dump_segments(int output_id)
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
if (orte_gpr_replica_globals.compound_cmd_mode) {
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_dump_segments(orte_gpr_replica_globals.compound_cmd))) {
ORTE_ERROR_LOG(rc);
}
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
buffer = OBJ_NEW(orte_buffer_t); buffer = OBJ_NEW(orte_buffer_t);
if (NULL == buffer) { if (NULL == buffer) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
@ -126,14 +110,6 @@ int orte_gpr_replica_dump_triggers(int output_id)
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
if (orte_gpr_replica_globals.compound_cmd_mode) {
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_dump_triggers(orte_gpr_replica_globals.compound_cmd))) {
ORTE_ERROR_LOG(rc);
}
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
buffer = OBJ_NEW(orte_buffer_t); buffer = OBJ_NEW(orte_buffer_t);
if (NULL == buffer) { if (NULL == buffer) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
@ -154,6 +130,33 @@ int orte_gpr_replica_dump_triggers(int output_id)
return rc; return rc;
} }
int orte_gpr_replica_dump_subscriptions(int output_id)
{
orte_buffer_t *buffer;
int rc;
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
buffer = OBJ_NEW(orte_buffer_t);
if (NULL == buffer) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_subscriptions_fn(buffer))) {
ORTE_ERROR_LOG(rc);
}
if (ORTE_SUCCESS == rc) {
orte_gpr_base_print_dump(buffer, output_id);
}
OBJ_RELEASE(buffer);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
int orte_gpr_replica_dump_callbacks(int output_id) int orte_gpr_replica_dump_callbacks(int output_id)
{ {
orte_buffer_t *buffer; orte_buffer_t *buffer;
@ -166,14 +169,6 @@ int orte_gpr_replica_dump_callbacks(int output_id)
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
if (orte_gpr_replica_globals.compound_cmd_mode) {
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_dump_callbacks(orte_gpr_replica_globals.compound_cmd))) {
ORTE_ERROR_LOG(rc);
}
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
buffer = OBJ_NEW(orte_buffer_t); buffer = OBJ_NEW(orte_buffer_t);
if (NULL == buffer) { if (NULL == buffer) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);

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

@ -49,10 +49,6 @@ int orte_gpr_replica_put(size_t cnt, orte_gpr_value_t **values)
return ORTE_ERROR; return ORTE_ERROR;
} }
if (orte_gpr_replica_globals.compound_cmd_mode) {
return orte_gpr_base_pack_put(orte_gpr_replica_globals.compound_cmd, cnt, values);
}
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
for (i=0; i < cnt; i++) { for (i=0; i < cnt; i++) {
@ -87,7 +83,7 @@ int orte_gpr_replica_put(size_t cnt, orte_gpr_value_t **values)
goto CLEANUP; goto CLEANUP;
} }
if (ORTE_SUCCESS != (rc = orte_gpr_replica_check_subscriptions(seg))) { if (ORTE_SUCCESS != (rc = orte_gpr_replica_check_events())) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
goto CLEANUP; goto CLEANUP;
} }
@ -104,7 +100,7 @@ CLEANUP:
free(itags); free(itags);
} }
if (ORTE_SUCCESS == rc && !orte_gpr_replica.processing_callbacks) { if (ORTE_SUCCESS == rc) {
rc = orte_gpr_replica_process_callbacks(); rc = orte_gpr_replica_process_callbacks();
} }
@ -139,11 +135,6 @@ int orte_gpr_replica_get(orte_gpr_addr_mode_t addr_mode,
return ORTE_ERR_BAD_PARAM; return ORTE_ERR_BAD_PARAM;
} }
if (orte_gpr_replica_globals.compound_cmd_mode) {
return orte_gpr_base_pack_get(orte_gpr_replica_globals.compound_cmd,
addr_mode, segment, tokens, keys);
}
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
/* find the segment */ /* find the segment */

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

@ -33,15 +33,12 @@
#include "gpr_replica_api.h" #include "gpr_replica_api.h"
int int
orte_gpr_replica_subscribe(orte_gpr_notify_action_t action, orte_gpr_replica_subscribe(size_t num_subs,
size_t num_subs,
orte_gpr_subscription_t **subscriptions, orte_gpr_subscription_t **subscriptions,
size_t num_trigs, size_t num_trigs,
orte_gpr_value_t **trigs, orte_gpr_trigger_t **trigs)
orte_gpr_notify_id_t *sub_number)
{ {
int rc; int rc;
orte_gpr_notify_id_t idtag;
/* protect against errors */ /* protect against errors */
if (NULL == subscriptions) { if (NULL == subscriptions) {
@ -49,58 +46,40 @@ orte_gpr_replica_subscribe(orte_gpr_notify_action_t action,
return ORTE_ERR_BAD_PARAM; return ORTE_ERR_BAD_PARAM;
} }
/* if this has a trigger in it, must specify the trigger condition */
if (ORTE_GPR_TRIG_ANY & action && NULL == trigs) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
if (orte_gpr_replica_globals.compound_cmd_mode) { /* store callback function and user_tag in local list for lookup
* generate id_tag to put in registry to identify lookup entry
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_subscribe(orte_gpr_replica_globals.compound_cmd, * for each subscription - the subscription id is returned
action, num_subs, subscriptions, num_trigs, trigs))) { * inside the subscription objects
ORTE_ERROR_LOG(rc); */
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex); if (ORTE_SUCCESS != (rc = orte_gpr_replica_enter_local_subscription(
return rc; num_subs, subscriptions))) {
}
/* enter request on notify tracking system */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_enter_notify_request(&idtag,
NULL, ORTE_GPR_NOTIFY_ID_MAX,
num_subs, subscriptions))) {
ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
*sub_number = idtag;
if (ORTE_SUCCESS != (rc = orte_dps.pack(orte_gpr_replica_globals.compound_cmd,
&idtag, 1, ORTE_GPR_NOTIFY_ID))) {
ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return ORTE_SUCCESS;
}
/* enter request on notify tracking system */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_enter_notify_request(&idtag,
NULL, ORTE_GPR_NOTIFY_ID_MAX,
num_subs, subscriptions))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc; return rc;
} }
*sub_number = idtag;
/* if any triggers were provided, get id tags for them - the
* idtags are returned inside the trigger objects
*/
if (ORTE_SUCCESS != (rc = orte_gpr_replica_enter_local_trigger(
num_trigs, trigs))) {
ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
/* register subscriptions */ /* register subscriptions */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_subscribe_fn(action, num_subs, if (ORTE_SUCCESS != (rc = orte_gpr_replica_subscribe_fn(NULL,
subscriptions, num_trigs, trigs, idtag))) { num_subs, subscriptions,
num_trigs, trigs))) {
ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_gpr_replica_check_events())) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc; return rc;
@ -114,18 +93,27 @@ orte_gpr_replica_subscribe(orte_gpr_notify_action_t action,
} }
int orte_gpr_replica_unsubscribe(orte_gpr_notify_id_t sub_number) int orte_gpr_replica_unsubscribe(orte_gpr_subscription_id_t sub_number)
{ {
int rc; int rc;
if (orte_gpr_replica_globals.compound_cmd_mode) {
return orte_gpr_base_pack_unsubscribe(orte_gpr_replica_globals.compound_cmd,
sub_number);
}
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
rc = orte_gpr_replica_unsubscribe_fn(sub_number); rc = orte_gpr_replica_remove_subscription(NULL, sub_number);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
int orte_gpr_replica_cancel_trigger(orte_gpr_trigger_id_t trig)
{
int rc;
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
rc = orte_gpr_replica_remove_trigger(NULL, trig);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);

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

@ -78,7 +78,7 @@ int orte_gpr_replica_recv_increment_value_cmd(orte_buffer_t *cmd, orte_buffer_t
if (ORTE_SUCCESS == ret) { if (ORTE_SUCCESS == ret) {
if (ORTE_SUCCESS != if (ORTE_SUCCESS !=
(rc = orte_gpr_replica_check_subscriptions(seg))) { (rc = orte_gpr_replica_check_events())) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
@ -141,7 +141,7 @@ int orte_gpr_replica_recv_decrement_value_cmd(orte_buffer_t *cmd, orte_buffer_t
if (ORTE_SUCCESS == ret) { if (ORTE_SUCCESS == ret) {
if (ORTE_SUCCESS != if (ORTE_SUCCESS !=
(rc = orte_gpr_replica_check_subscriptions(seg))) { (rc = orte_gpr_replica_check_events())) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }

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

@ -161,18 +161,33 @@ int orte_gpr_replica_process_command_buffer(orte_buffer_t *input_buffer,
} }
if (ORTE_SUCCESS != (ret = if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_unsubscribe_cmd(input_buffer, answer))) { orte_gpr_replica_recv_unsubscribe_cmd(sender, input_buffer, answer))) {
ORTE_ERROR_LOG(ret); ORTE_ERROR_LOG(ret);
goto RETURN_ERROR; goto RETURN_ERROR;
} }
break; break;
case ORTE_GPR_CANCEL_TRIGGER_CMD: /***** CANCEL_TRIGGER *****/
if (orte_gpr_replica_globals.debug) {
ompi_output(0, "\tcancel trigger cmd");
}
if (ORTE_SUCCESS != (ret =
orte_gpr_replica_recv_cancel_trigger_cmd(sender, input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_ALL_CMD: /***** DUMP *****/ case ORTE_GPR_DUMP_ALL_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) { if (orte_gpr_replica_globals.debug) {
ompi_output(0, "\tdump cmd"); ompi_output(0, "\tdump all cmd");
} }
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_all_cmd(answer))) { if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_all_cmd(answer))) {
@ -186,7 +201,7 @@ int orte_gpr_replica_process_command_buffer(orte_buffer_t *input_buffer,
case ORTE_GPR_DUMP_SEGMENTS_CMD: /***** DUMP *****/ case ORTE_GPR_DUMP_SEGMENTS_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) { if (orte_gpr_replica_globals.debug) {
ompi_output(0, "\tdump cmd"); ompi_output(0, "\tdump segments cmd");
} }
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_segments_cmd(answer))) { if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_segments_cmd(answer))) {
@ -200,7 +215,7 @@ int orte_gpr_replica_process_command_buffer(orte_buffer_t *input_buffer,
case ORTE_GPR_DUMP_TRIGGERS_CMD: /***** DUMP *****/ case ORTE_GPR_DUMP_TRIGGERS_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) { if (orte_gpr_replica_globals.debug) {
ompi_output(0, "\tdump cmd"); ompi_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(answer))) {
@ -211,10 +226,24 @@ int orte_gpr_replica_process_command_buffer(orte_buffer_t *input_buffer,
case ORTE_GPR_DUMP_SUBSCRIPTIONS_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
ompi_output(0, "\tdump subscriptions cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_subscriptions_cmd(answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_CALLBACKS_CMD: /***** DUMP *****/ case ORTE_GPR_DUMP_CALLBACKS_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) { if (orte_gpr_replica_globals.debug) {
ompi_output(0, "\tdump cmd"); ompi_output(0, "\tdump callbacks cmd");
} }
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_callbacks_cmd(answer))) { if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_callbacks_cmd(answer))) {

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

@ -72,7 +72,8 @@ int orte_gpr_replica_process_command_buffer(orte_buffer_t *input_buffer,
/* /*
* Messaging functions * Messaging functions
*/ */
int orte_gpr_replica_remote_notify(orte_process_name_t *recipient, ompi_list_t *messages); int orte_gpr_replica_remote_notify(orte_process_name_t *recipient,
orte_gpr_notify_message_t *msg);
/* /*
* define the local functions for processing commands * define the local functions for processing commands
@ -98,15 +99,22 @@ int orte_gpr_replica_recv_subscribe_cmd(orte_process_name_t* sender,
orte_buffer_t *input_buffer, orte_buffer_t *input_buffer,
orte_buffer_t *output_buffer); orte_buffer_t *output_buffer);
int orte_gpr_replica_recv_unsubscribe_cmd(orte_buffer_t *input_buffer, int orte_gpr_replica_recv_unsubscribe_cmd(orte_process_name_t* sender,
orte_buffer_t *input_buffer,
orte_buffer_t *output_buffer); orte_buffer_t *output_buffer);
int orte_gpr_replica_recv_cancel_trigger_cmd(orte_process_name_t* sender,
orte_buffer_t *input_buffer,
orte_buffer_t *output_buffer);
int orte_gpr_replica_recv_dump_all_cmd(orte_buffer_t *answer); int orte_gpr_replica_recv_dump_all_cmd(orte_buffer_t *answer);
int orte_gpr_replica_recv_dump_segments_cmd(orte_buffer_t *answer); int orte_gpr_replica_recv_dump_segments_cmd(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 *answer);
int orte_gpr_replica_recv_dump_subscriptions_cmd(orte_buffer_t *answer);
int orte_gpr_replica_recv_dump_callbacks_cmd(orte_buffer_t *answer); int orte_gpr_replica_recv_dump_callbacks_cmd(orte_buffer_t *answer);
int orte_gpr_replica_recv_get_startup_msg_cmd(orte_buffer_t *input_buffer, int orte_gpr_replica_recv_get_startup_msg_cmd(orte_buffer_t *input_buffer,

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

@ -157,7 +157,7 @@ int orte_gpr_replica_recv_delete_entries_cmd(orte_buffer_t *buffer, orte_buffer_
key_itags, num_keys); key_itags, num_keys);
if (ORTE_SUCCESS == ret) { if (ORTE_SUCCESS == ret) {
orte_gpr_replica_check_subscriptions(seg); orte_gpr_replica_check_events();
} }

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

@ -85,6 +85,24 @@ int orte_gpr_replica_recv_dump_triggers_cmd(orte_buffer_t *answer)
return rc; return rc;
} }
int orte_gpr_replica_recv_dump_subscriptions_cmd(orte_buffer_t *answer)
{
orte_gpr_cmd_flag_t command=ORTE_GPR_DUMP_SUBSCRIPTIONS_CMD;
int rc;
if (ORTE_SUCCESS != (rc = orte_dps.pack(answer, &command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
return rc;
}
rc = orte_gpr_replica_dump_subscriptions_fn(answer);
if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
int orte_gpr_replica_recv_dump_callbacks_cmd(orte_buffer_t *answer) int orte_gpr_replica_recv_dump_callbacks_cmd(orte_buffer_t *answer)
{ {
orte_gpr_cmd_flag_t command=ORTE_GPR_DUMP_CALLBACKS_CMD; orte_gpr_cmd_flag_t command=ORTE_GPR_DUMP_CALLBACKS_CMD;

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

@ -98,7 +98,7 @@ int orte_gpr_replica_recv_put_cmd(orte_buffer_t *buffer, orte_buffer_t *answer)
if (ORTE_SUCCESS == ret) { if (ORTE_SUCCESS == ret) {
if (ORTE_SUCCESS != if (ORTE_SUCCESS !=
(rc = orte_gpr_replica_check_subscriptions(seg))) { (rc = orte_gpr_replica_check_events())) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }

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

@ -34,13 +34,11 @@
#include "gpr_replica_comm.h" #include "gpr_replica_comm.h"
int orte_gpr_replica_remote_notify(orte_process_name_t *recipient, ompi_list_t *messages) int orte_gpr_replica_remote_notify(orte_process_name_t *recipient,
orte_gpr_notify_message_t *message)
{ {
orte_buffer_t buffer; orte_buffer_t buffer;
orte_gpr_replica_notify_msg_list_t *msg;
orte_gpr_notify_message_t *message;
orte_gpr_cmd_flag_t command; orte_gpr_cmd_flag_t command;
size_t count;
int rc; int rc;
if (orte_gpr_replica_globals.debug) { if (orte_gpr_replica_globals.debug) {
@ -56,36 +54,20 @@ int orte_gpr_replica_remote_notify(orte_process_name_t *recipient, ompi_list_t *
return rc; return rc;
} }
count = (size_t)ompi_list_get_size(messages); if (ORTE_SUCCESS != (rc = orte_dps.pack(&buffer, &(message->cnt), 1, ORTE_SIZE))) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(&buffer, &count, 1, ORTE_SIZE))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
while (NULL != (msg = (orte_gpr_replica_notify_msg_list_t*)ompi_list_remove_first(messages))) {
message = msg->message;
if (ORTE_SUCCESS != (rc = orte_dps.pack(&buffer, &(message->idtag), 1, ORTE_GPR_NOTIFY_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(&buffer, &(message->cnt), 1, ORTE_SIZE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if(message->cnt > 0) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(&buffer, message->data, message->cnt, ORTE_GPR_NOTIFY_DATA))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
OBJ_RELEASE(msg);
}
if(message->cnt > 0) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(&buffer, message->data,
message->cnt, ORTE_GPR_NOTIFY_DATA))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
OBJ_RELEASE(message);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex); OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
if (0 > orte_rml.send_buffer(recipient, &buffer, ORTE_RML_TAG_GPR_NOTIFY, 0)) { if (0 > orte_rml.send_buffer(recipient, &buffer, ORTE_RML_TAG_GPR_NOTIFY, 0)) {

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

@ -38,11 +38,9 @@ int orte_gpr_replica_recv_subscribe_cmd(orte_process_name_t* sender,
{ {
orte_gpr_cmd_flag_t command=ORTE_GPR_SUBSCRIBE_CMD; orte_gpr_cmd_flag_t command=ORTE_GPR_SUBSCRIBE_CMD;
orte_data_type_t type; orte_data_type_t type;
orte_gpr_notify_id_t local_idtag=ORTE_GPR_NOTIFY_ID_MAX, idtag=ORTE_GPR_NOTIFY_ID_MAX;
int rc, ret; int rc, ret;
size_t n, num_subs, num_trigs; size_t n, num_subs, num_trigs;
orte_gpr_notify_action_t action; orte_gpr_trigger_t **trigs=NULL;
orte_gpr_value_t **trigs=NULL;
orte_gpr_subscription_t **subscriptions=NULL; orte_gpr_subscription_t **subscriptions=NULL;
if (ORTE_SUCCESS != (rc = orte_dps.pack(output_buffer, &command, 1, ORTE_GPR_CMD))) { if (ORTE_SUCCESS != (rc = orte_dps.pack(output_buffer, &command, 1, ORTE_GPR_CMD))) {
@ -50,12 +48,6 @@ int orte_gpr_replica_recv_subscribe_cmd(orte_process_name_t* sender,
return rc; return rc;
} }
n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(input_buffer, &action, &n, ORTE_NOTIFY_ACTION))) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
if (ORTE_SUCCESS != (rc = orte_dps.peek(input_buffer, &type, &n))) { if (ORTE_SUCCESS != (rc = orte_dps.peek(input_buffer, &type, &n))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
goto RETURN_ERROR; goto RETURN_ERROR;
@ -84,70 +76,37 @@ int orte_gpr_replica_recv_subscribe_cmd(orte_process_name_t* sender,
if (0 < n) { if (0 < n) {
/* create the space for the triggers */ /* create the space for the triggers */
trigs = (orte_gpr_value_t**)malloc(n * sizeof(orte_gpr_value_t*)); trigs = (orte_gpr_trigger_t**)malloc(n * sizeof(orte_gpr_trigger_t*));
if (NULL == trigs) { if (NULL == trigs) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE; rc = ORTE_ERR_OUT_OF_RESOURCE;
goto RETURN_ERROR; goto RETURN_ERROR;
} }
if (ORTE_SUCCESS != orte_dps.unpack(input_buffer, trigs, &n, ORTE_GPR_VALUE)) { if (ORTE_SUCCESS != orte_dps.unpack(input_buffer, trigs, &n, ORTE_GPR_TRIGGER)) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
goto RETURN_ERROR; goto RETURN_ERROR;
} }
} }
num_trigs = n; num_trigs = n;
n = 1;
if (ORTE_SUCCESS != orte_dps.unpack(input_buffer, &idtag, &n, ORTE_GPR_NOTIFY_ID)) { /* register subscriptions */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_subscribe_fn(sender,
num_subs, subscriptions,
num_trigs, trigs))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
goto RETURN_ERROR; OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
} }
if (NULL != sender) { /* remote sender */ if (ORTE_SUCCESS != (rc = orte_gpr_replica_check_events())) {
ORTE_ERROR_LOG(rc);
if (orte_gpr_replica_globals.debug) { OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
ompi_output(0, "[%lu,%lu,%lu] subscribe requested for remote sender [%lu,%lu,%lu] for idtag %d", return rc;
ORTE_NAME_ARGS(orte_process_info.my_name), ORTE_NAME_ARGS(sender), idtag);
}
/* enter request on local notify tracking system */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_enter_notify_request(&local_idtag,
sender, idtag, num_subs, subscriptions))) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
/* register subscriptions */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_subscribe_fn(action,
num_subs, subscriptions,
num_trigs, trigs,
local_idtag))) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
} else { /* local sender - idtag is for local notify tracking system */
/* register subscription */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_subscribe_fn(action,
num_subs, subscriptions,
num_trigs, trigs,
idtag))) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
/* set the local idtag for return to local sender */
local_idtag = idtag;
} }
RETURN_ERROR: RETURN_ERROR:
/* pack the local idtag for return to sender */
if (ORTE_SUCCESS != (rc = orte_dps.pack(output_buffer, &local_idtag, 1, ORTE_GPR_NOTIFY_ID))) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
if (ORTE_SUCCESS != (ret = orte_dps.pack(output_buffer, &rc, 1, ORTE_INT))) { if (ORTE_SUCCESS != (ret = orte_dps.pack(output_buffer, &rc, 1, ORTE_INT))) {
ORTE_ERROR_LOG(ret); ORTE_ERROR_LOG(ret);
return ret; return ret;
@ -156,11 +115,12 @@ int orte_gpr_replica_recv_subscribe_cmd(orte_process_name_t* sender,
return rc; return rc;
} }
int orte_gpr_replica_recv_unsubscribe_cmd(orte_buffer_t *input_buffer, int orte_gpr_replica_recv_unsubscribe_cmd(orte_process_name_t *sender,
orte_buffer_t *input_buffer,
orte_buffer_t *output_buffer) orte_buffer_t *output_buffer)
{ {
orte_gpr_cmd_flag_t command=ORTE_GPR_UNSUBSCRIBE_CMD; orte_gpr_cmd_flag_t command=ORTE_GPR_UNSUBSCRIBE_CMD;
orte_gpr_notify_id_t sub_number=0; orte_gpr_subscription_id_t sub_number=0;
int rc, ret; int rc, ret;
size_t n; size_t n;
@ -170,13 +130,51 @@ int orte_gpr_replica_recv_unsubscribe_cmd(orte_buffer_t *input_buffer,
} }
n = 1; n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(input_buffer, &sub_number, &n, ORTE_GPR_NOTIFY_ID))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(input_buffer, &sub_number, &n,
ORTE_GPR_SUBSCRIPTION_ID))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
ret = rc; ret = rc;
goto RETURN_ERROR; goto RETURN_ERROR;
} }
ret = orte_gpr_replica_unsubscribe_fn(sub_number); ret = orte_gpr_replica_remove_subscription(sender, sub_number);
if (ORTE_SUCCESS != ret) {
ORTE_ERROR_LOG(ret);
}
RETURN_ERROR:
if (ORTE_SUCCESS != (rc = orte_dps.pack(output_buffer, &ret, 1, ORTE_INT))) {
ORTE_ERROR_LOG(rc);
return rc;
}
return ret;
}
int orte_gpr_replica_recv_cancel_trigger_cmd(orte_process_name_t *sender,
orte_buffer_t *input_buffer,
orte_buffer_t *output_buffer)
{
orte_gpr_cmd_flag_t command=ORTE_GPR_CANCEL_TRIGGER_CMD;
orte_gpr_trigger_id_t trig_number=0;
int rc, ret;
size_t n;
if (ORTE_SUCCESS != (rc = orte_dps.pack(output_buffer, &command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
return rc;
}
n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(input_buffer, &trig_number, &n,
ORTE_GPR_TRIGGER_ID))) {
ORTE_ERROR_LOG(rc);
ret = rc;
goto RETURN_ERROR;
}
ret = orte_gpr_replica_remove_trigger(sender, trig_number);
if (ORTE_SUCCESS != ret) { if (ORTE_SUCCESS != ret) {
ORTE_ERROR_LOG(ret); ORTE_ERROR_LOG(ret);
} }

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

@ -44,7 +44,7 @@ int orte_gpr_replica_increment_value_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_addr_mode_t tok_mode; orte_gpr_replica_addr_mode_t tok_mode;
orte_gpr_replica_itagval_t **ival; orte_gpr_replica_itagval_t **ival;
int rc; int rc;
size_t i, j, k, num_found; size_t i, j, k, m, n;
/* extract the token address mode */ /* extract the token address mode */
tok_mode = 0x004f & addr_mode; tok_mode = 0x004f & addr_mode;
@ -53,13 +53,13 @@ int orte_gpr_replica_increment_value_fn(orte_gpr_addr_mode_t addr_mode,
} }
/* find the specified container(s) */ /* find the specified container(s) */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_containers(&num_found, seg, tok_mode, if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_containers(seg, tok_mode,
tokentags, num_tokens))) { tokentags, num_tokens))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
if (0 == num_found) { /* nothing found */ if (0 == orte_gpr_replica_globals.num_srch_cptr) { /* nothing found */
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND); ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND; return ORTE_ERR_NOT_FOUND;
} }
@ -67,16 +67,20 @@ int orte_gpr_replica_increment_value_fn(orte_gpr_addr_mode_t addr_mode,
/* otherwise, go through list of containers. For each one, /* otherwise, go through list of containers. For each one,
find the entry and then add one to its value */ find the entry and then add one to its value */
cptr = (orte_gpr_replica_container_t**)(orte_gpr_replica_globals.srch_cptr)->addr; cptr = (orte_gpr_replica_container_t**)(orte_gpr_replica_globals.srch_cptr)->addr;
for (j=0; j < (orte_gpr_replica_globals.srch_cptr)->size; j++) { /* for each container */ for (j=0, m=0; m < orte_gpr_replica_globals.num_srch_cptr &&
j < (orte_gpr_replica_globals.srch_cptr)->size; j++) { /* for each container */
if (NULL != cptr[j]) { if (NULL != cptr[j]) {
m++;
for (i=0; i < cnt; i++) { /* for each provided keyval to be incremented */ for (i=0; i < cnt; i++) { /* for each provided keyval to be incremented */
if (ORTE_SUCCESS == orte_gpr_replica_dict_lookup(&itag, seg, keyvals[i]->key) && if (ORTE_SUCCESS == orte_gpr_replica_dict_lookup(&itag, seg, keyvals[i]->key) &&
ORTE_SUCCESS == orte_gpr_replica_search_container(&num_found, ORTE_SUCCESS == orte_gpr_replica_search_container(
ORTE_GPR_REPLICA_OR, &itag, 1, cptr[j]) && ORTE_GPR_REPLICA_OR, &itag, 1, cptr[j]) &&
0 < num_found) { 0 < orte_gpr_replica_globals.num_srch_ival) {
ival = (orte_gpr_replica_itagval_t**)((orte_gpr_replica_globals.srch_ival)->addr); ival = (orte_gpr_replica_itagval_t**)((orte_gpr_replica_globals.srch_ival)->addr);
for (k=0; k < (orte_gpr_replica_globals.srch_ival)->size; k++) { /* for each found keyval */ for (k=0, n=0; n < orte_gpr_replica_globals.num_srch_ival &&
k < (orte_gpr_replica_globals.srch_ival)->size; k++) { /* for each found keyval */
if (NULL != ival[k]) { if (NULL != ival[k]) {
n++;
switch (ival[k]->type) { switch (ival[k]->type) {
case ORTE_SIZE: case ORTE_SIZE:
ival[k]->value.size++; ival[k]->value.size++;
@ -138,7 +142,7 @@ int orte_gpr_replica_decrement_value_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_addr_mode_t tok_mode; orte_gpr_replica_addr_mode_t tok_mode;
orte_gpr_replica_itagval_t **ival; orte_gpr_replica_itagval_t **ival;
int rc; int rc;
size_t i, j, k, num_found; size_t i, j, k, m, n;
/* extract the token address mode */ /* extract the token address mode */
tok_mode = 0x004f & addr_mode; tok_mode = 0x004f & addr_mode;
@ -147,30 +151,34 @@ int orte_gpr_replica_decrement_value_fn(orte_gpr_addr_mode_t addr_mode,
} }
/* find the specified container(s) */ /* find the specified container(s) */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_containers(&num_found, seg, tok_mode, if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_containers(seg, tok_mode,
tokentags, num_tokens))) { tokentags, num_tokens))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
if (0 == num_found) { /* nothing found */ if (0 == orte_gpr_replica_globals.num_srch_cptr) { /* nothing found */
/* no ERROR_LOG entry created as this is not a system failure */ ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND; return ORTE_ERR_NOT_FOUND;
} }
/* otherwise, go through list of containers. For each one, /* otherwise, go through list of containers. For each one,
find the entry and then add one to its value */ find the entry and then add one to its value */
cptr = (orte_gpr_replica_container_t**)(orte_gpr_replica_globals.srch_cptr)->addr; cptr = (orte_gpr_replica_container_t**)(orte_gpr_replica_globals.srch_cptr)->addr;
for (j=0; j < (orte_gpr_replica_globals.srch_cptr)->size; j++) { /* for each container */ for (j=0, m=0; m < orte_gpr_replica_globals.num_srch_cptr &&
j < (orte_gpr_replica_globals.srch_cptr)->size; j++) { /* for each container */
if (NULL != cptr[j]) { if (NULL != cptr[j]) {
for (i=0; i < cnt; i++) { /* for each provided keyval to be decremented */ m++;
for (i=0; i < cnt; i++) { /* for each provided keyval to be incremented */
if (ORTE_SUCCESS == orte_gpr_replica_dict_lookup(&itag, seg, keyvals[i]->key) && if (ORTE_SUCCESS == orte_gpr_replica_dict_lookup(&itag, seg, keyvals[i]->key) &&
ORTE_SUCCESS == orte_gpr_replica_search_container(&num_found, ORTE_SUCCESS == orte_gpr_replica_search_container(
ORTE_GPR_REPLICA_OR, &itag, 1, cptr[j]) && ORTE_GPR_REPLICA_OR, &itag, 1, cptr[j]) &&
0 < num_found) { 0 < orte_gpr_replica_globals.num_srch_ival) {
ival = (orte_gpr_replica_itagval_t**)((orte_gpr_replica_globals.srch_ival)->addr); ival = (orte_gpr_replica_itagval_t**)((orte_gpr_replica_globals.srch_ival)->addr);
for (k=0; k < (orte_gpr_replica_globals.srch_ival)->size; k++) { /* for each found keyval */ for (k=0, n=0; n < orte_gpr_replica_globals.num_srch_ival &&
k < (orte_gpr_replica_globals.srch_ival)->size; k++) { /* for each found keyval */
if (NULL != ival[k]) { if (NULL != ival[k]) {
n++;
switch (ival[k]->type) { switch (ival[k]->type) {
case ORTE_SIZE: case ORTE_SIZE:
ival[k]->value.size--; ival[k]->value.size--;

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

@ -44,7 +44,7 @@ void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer,
orte_gpr_replica_itagval_t *iptr); orte_gpr_replica_itagval_t *iptr);
static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt, static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt,
orte_gpr_replica_triggers_t *trig); orte_gpr_replica_trigger_t *trig);
int orte_gpr_replica_dump_all_fn(orte_buffer_t *buffer) int orte_gpr_replica_dump_all_fn(orte_buffer_t *buffer)
@ -60,6 +60,10 @@ int orte_gpr_replica_dump_all_fn(orte_buffer_t *buffer)
return rc; return rc;
} }
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_subscriptions_fn(buffer))) {
return rc;
}
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_callbacks_fn(buffer))) { if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_callbacks_fn(buffer))) {
return rc; return rc;
} }
@ -77,7 +81,7 @@ int orte_gpr_replica_dump_segments_fn(orte_buffer_t *buffer)
orte_gpr_replica_itagval_t **iptr; orte_gpr_replica_itagval_t **iptr;
char *token; char *token;
size_t num_objects; size_t num_objects;
size_t i, j, k; size_t i, j, k, m, n, p;
char *tmp_out; char *tmp_out;
tmp_out = (char*)malloc(1000); tmp_out = (char*)malloc(1000);
@ -91,9 +95,10 @@ int orte_gpr_replica_dump_segments_fn(orte_buffer_t *buffer)
/* loop through all segments */ /* loop through all segments */
seg = (orte_gpr_replica_segment_t**)(orte_gpr_replica.segments)->addr; seg = (orte_gpr_replica_segment_t**)(orte_gpr_replica.segments)->addr;
for (i=0; i < (orte_gpr_replica.segments)->size; i++) { for (i=0, m=0; m < orte_gpr_replica.num_segs &&
i < (orte_gpr_replica.segments)->size; i++) {
if (NULL != seg[i]) { if (NULL != seg[i]) {
m++;
sprintf(tmp_out, "\nGPR Dump for Segment: %s", seg[i]->name); sprintf(tmp_out, "\nGPR Dump for Segment: %s", seg[i]->name);
orte_gpr_replica_dump_load_string(buffer, &tmp_out); orte_gpr_replica_dump_load_string(buffer, &tmp_out);
@ -105,8 +110,10 @@ int orte_gpr_replica_dump_segments_fn(orte_buffer_t *buffer)
/* loop through all containers and print their info and contents */ /* loop through all containers and print their info and contents */
cptr = (orte_gpr_replica_container_t**)(seg[i]->containers)->addr; cptr = (orte_gpr_replica_container_t**)(seg[i]->containers)->addr;
for (j=0; j < (seg[i]->containers)->size; j++) { for (j=0, n=0; n < seg[i]->num_containers &&
j < (seg[i]->containers)->size; j++) {
if (NULL != cptr[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" "\tNumber of keyvals: %lu"
"\n\tTokens:\n", "\n\tTokens:\n",
@ -137,8 +144,10 @@ int orte_gpr_replica_dump_segments_fn(orte_buffer_t *buffer)
/* loop through all itagvals and print their info */ /* loop through all itagvals and print their info */
iptr = (orte_gpr_replica_itagval_t**)(cptr[j]->itagvals)->addr; iptr = (orte_gpr_replica_itagval_t**)(cptr[j]->itagvals)->addr;
for (k=0; k < (cptr[j]->itagvals)->size; k++) { for (k=0, p=0; p < cptr[j]->num_itagvals &&
k < (cptr[j]->itagvals)->size; k++) {
if (NULL != iptr[k]) { if (NULL != iptr[k]) {
p++;
if (ORTE_SUCCESS != orte_gpr_replica_dict_reverse_lookup( if (ORTE_SUCCESS != orte_gpr_replica_dict_reverse_lookup(
&token, seg[i], iptr[k]->itag)) { &token, seg[i], iptr[k]->itag)) {
sprintf(tmp_out, "\n\t\titag num %lu: No entry found for itag %lu", sprintf(tmp_out, "\n\t\titag num %lu: No entry found for itag %lu",
@ -166,9 +175,7 @@ int orte_gpr_replica_dump_segments_fn(orte_buffer_t *buffer)
int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer) int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer)
{ {
ompi_list_item_t *item;
orte_gpr_replica_callbacks_t *cb; orte_gpr_replica_callbacks_t *cb;
orte_gpr_replica_notify_msg_list_t *msg;
orte_gpr_replica_action_taken_t **action; orte_gpr_replica_action_taken_t **action;
orte_gpr_replica_itag_t *itaglist; orte_gpr_replica_itag_t *itaglist;
char *tmp_out, *token; char *tmp_out, *token;
@ -210,35 +217,22 @@ int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer)
ORTE_NAME_ARGS(cb->requestor)); ORTE_NAME_ARGS(cb->requestor));
} }
orte_gpr_replica_dump_load_string(buffer, &tmp_out); orte_gpr_replica_dump_load_string(buffer, &tmp_out);
j = ompi_list_get_size(&(cb->messages)); orte_gpr_base_dump_notify_msg(buffer, cb->message);
sprintf(tmp_out, "Num messages: %lu", (unsigned long) j);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
for (k=0, item = ompi_list_get_first(&(cb->messages));
item != ompi_list_get_end(&(cb->messages));
item = ompi_list_get_next(item), k++) {
msg = (orte_gpr_replica_notify_msg_list_t*)item;
sprintf(tmp_out, "\n\nInfo for message %lu sending %lu "
" data objects to notifier id %lu",
(unsigned long) k, (unsigned long) (msg->message)->cnt,
(unsigned long) (msg->message)->idtag);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
orte_gpr_base_dump_notify_msg(buffer, msg->message);
}
i++;
} }
} }
sprintf(tmp_out, "\n"); sprintf(tmp_out, "\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out); orte_gpr_replica_dump_load_string(buffer, &tmp_out);
i = (orte_gpr_replica_globals.acted_upon)->size - (orte_gpr_replica_globals.acted_upon)->number_free; if (0 < orte_gpr_replica_globals.num_acted_upon) {
if (0 < i) {
sprintf(tmp_out, "\nDUMP OF GPR ACTION RECORDS\n"); sprintf(tmp_out, "\nDUMP OF GPR ACTION RECORDS\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out); orte_gpr_replica_dump_load_string(buffer, &tmp_out);
action = (orte_gpr_replica_action_taken_t**)orte_gpr_replica_globals.acted_upon->addr; action = (orte_gpr_replica_action_taken_t**)orte_gpr_replica_globals.acted_upon->addr;
for (i=0; i < (orte_gpr_replica_globals.acted_upon)->size; i++) { for (i=0, j=0; j < orte_gpr_replica_globals.num_acted_upon &&
i < (orte_gpr_replica_globals.acted_upon)->size; i++) {
if (NULL != action[i]) { if (NULL != action[i]) {
j++;
if (NULL != action[i]->seg) { if (NULL != action[i]->seg) {
sprintf(tmp_out, "\nAction Taken on Segment: %s", action[i]->seg->name); sprintf(tmp_out, "\nAction Taken on Segment: %s", action[i]->seg->name);
orte_gpr_replica_dump_load_string(buffer, &tmp_out); orte_gpr_replica_dump_load_string(buffer, &tmp_out);
@ -322,7 +316,7 @@ int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer)
int orte_gpr_replica_dump_triggers_fn(orte_buffer_t *buffer) int orte_gpr_replica_dump_triggers_fn(orte_buffer_t *buffer)
{ {
orte_gpr_replica_triggers_t **trig; orte_gpr_replica_trigger_t **trig;
char tmp_out[100], *tmp; char tmp_out[100], *tmp;
size_t j, k; size_t j, k;
@ -330,17 +324,13 @@ int orte_gpr_replica_dump_triggers_fn(orte_buffer_t *buffer)
sprintf(tmp_out, "\nDUMP OF GPR TRIGGERS\n"); sprintf(tmp_out, "\nDUMP OF GPR TRIGGERS\n");
orte_gpr_replica_dump_load_string(buffer, &tmp); orte_gpr_replica_dump_load_string(buffer, &tmp);
trig = (orte_gpr_replica_triggers_t**)((orte_gpr_replica.triggers)->addr); trig = (orte_gpr_replica_trigger_t**)((orte_gpr_replica.triggers)->addr);
k = 0; sprintf(tmp_out, "Number of triggers: %lu\n", (unsigned long) orte_gpr_replica.num_trigs);
for (j=0; j < (orte_gpr_replica.triggers)->size; j++) {
if (NULL != trig[j]) k++;
}
sprintf(tmp_out, "Number of triggers: %lu\n", (unsigned long) k);
orte_gpr_replica_dump_load_string(buffer, &tmp); orte_gpr_replica_dump_load_string(buffer, &tmp);
/* dump the trigger info for the registry */ /* dump the trigger info for the registry */
for (j=0, k=0; j < (orte_gpr_replica.triggers)->size; j++) { for (j=0, k=0; k < orte_gpr_replica.num_trigs &&
j < (orte_gpr_replica.triggers)->size; j++) {
if (NULL != trig[j]) { if (NULL != trig[j]) {
orte_gpr_replica_dump_trigger(buffer, k, trig[j]); orte_gpr_replica_dump_trigger(buffer, k, trig[j]);
k++; k++;
@ -351,12 +341,12 @@ int orte_gpr_replica_dump_triggers_fn(orte_buffer_t *buffer)
} }
static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt, static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt,
orte_gpr_replica_triggers_t *trig) orte_gpr_replica_trigger_t *trig)
{ {
char *tmp_out, *token; char *tmp_out, *token;
size_t i, j, k; size_t i, j;
orte_gpr_replica_subscribed_data_t **data;
orte_gpr_replica_counter_t **cntr; orte_gpr_replica_counter_t **cntr;
orte_gpr_replica_subscription_t **subs;
tmp_out = (char*)malloc(1000); tmp_out = (char*)malloc(1000);
if (NULL == tmp_out) { if (NULL == tmp_out) {
@ -364,44 +354,9 @@ static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt,
return; return;
} }
sprintf(tmp_out, "\nData for trigger %lu", (unsigned long) cnt); sprintf(tmp_out, "\nData for trigger %lu", (unsigned long) trig->index);
orte_gpr_replica_dump_load_string(buffer, &tmp_out); orte_gpr_replica_dump_load_string(buffer, &tmp_out);
/* output recipient info */
if (NULL == trig->requestor) {
sprintf(tmp_out, "\tIntended recipient: LOCAL @ notifier idtag %lu",
(unsigned long) trig->index);
} else {
sprintf(tmp_out, "\tIntended recipient: [%lu,%lu,%lu] @ notifier idtag %lu",
ORTE_NAME_ARGS(trig->requestor),
(unsigned long) trig->remote_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 & trig->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_VALUE_CHG");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
} else if (ORTE_GPR_NOTIFY_VALUE_CHG_TO & trig->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_VALUE_CHG_TO");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
} else if (ORTE_GPR_NOTIFY_VALUE_CHG_FRM & trig->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_VALUE_CHG_FRM");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_NOTIFY_DEL_ENTRY & trig->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_DEL_ENTRY");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_NOTIFY_ADD_ENTRY & trig->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_ADD_ENTRY");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_NOTIFY_PRE_EXISTING & trig->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_PRE_EXISTING");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TRIG_ONE_SHOT & trig->action) { if (ORTE_GPR_TRIG_ONE_SHOT & trig->action) {
sprintf(tmp_out, "\t\tORTE_GPR_TRIG_ONE_SHOT"); sprintf(tmp_out, "\t\tORTE_GPR_TRIG_ONE_SHOT");
orte_gpr_replica_dump_load_string(buffer, &tmp_out); orte_gpr_replica_dump_load_string(buffer, &tmp_out);
@ -414,116 +369,11 @@ static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt,
sprintf(tmp_out, "\t\tORTE_GPR_TRIG_CMP_LEVELS"); sprintf(tmp_out, "\t\tORTE_GPR_TRIG_CMP_LEVELS");
orte_gpr_replica_dump_load_string(buffer, &tmp_out); orte_gpr_replica_dump_load_string(buffer, &tmp_out);
} }
if (ORTE_GPR_TRIG_MONITOR_ONLY & trig->action) {
sprintf(tmp_out, "\t\tORTE_GPR_TRIG_MONITOR_ONLY");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG & trig->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_STARTS_AFTER_TRIG");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TRIG_INCLUDE_DATA & trig->action) { if (ORTE_GPR_TRIG_INCLUDE_DATA & trig->action) {
sprintf(tmp_out, "\t\tORTE_GPR_TRIG_INCLUDE_DATA"); sprintf(tmp_out, "\t\tORTE_GPR_TRIG_INCLUDE_DATA");
orte_gpr_replica_dump_load_string(buffer, &tmp_out); orte_gpr_replica_dump_load_string(buffer, &tmp_out);
} }
sprintf(tmp_out, "\n\tData covered by this subscription");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
data = (orte_gpr_replica_subscribed_data_t**)((trig->subscribed_data)->addr);
for (i=0; i < (trig->subscribed_data)->size; i++) {
if (NULL != data[i]) {
sprintf(tmp_out, "\n\t\tData on segment %s", (data[i]->seg)->name);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
k = (int)orte_value_array_get_size(&(data[i]->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",
(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, data[i]->seg,
ORTE_VALUE_ARRAY_GET_ITEM(&(data[i]->tokentags), orte_gpr_replica_itag_t, j))) {
sprintf(tmp_out, "\t\t\tToken: %s", token);
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 & data[i]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_TOKENS_NOT\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_AND & data[i]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_TOKENS_AND\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_OR & data[i]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_TOKENS_OR\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_XAND & data[i]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_TOKENS_XAND\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_XOR & data[i]->addr_mode) {
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(&(data[i]->keytags));
if (0 == k) {
sprintf(tmp_out, "\t\tNULL key (wildcard)");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
} 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, data[i]->seg,
ORTE_VALUE_ARRAY_GET_ITEM(&(data[i]->keytags), orte_gpr_replica_itag_t, j))) {
sprintf(tmp_out, "\t\t\tKey: %s", token);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
free(token);
}
}
}
sprintf(tmp_out, "\t\tKey addressing mode:\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
if (ORTE_GPR_KEYS_NOT & data[i]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_KEYS_NOT\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_AND & data[i]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_KEYS_AND\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_OR & data[i]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_KEYS_OR\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_XAND & data[i]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_KEYS_XAND\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_XOR & data[i]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_KEYS_XOR\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
} /* if data[i] not NULL */
} /* for i */
if (0 < trig->num_counters) { if (0 < trig->num_counters) {
if (ORTE_GPR_TRIG_AT_LEVEL & trig->action) { 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",
@ -534,10 +384,12 @@ static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt,
} }
orte_gpr_replica_dump_load_string(buffer, &tmp_out); orte_gpr_replica_dump_load_string(buffer, &tmp_out);
cntr = (orte_gpr_replica_counter_t**)((trig->counters)->addr); cntr = (orte_gpr_replica_counter_t**)((trig->counters)->addr);
for (i=0; i < (trig->counters)->size; i++) { for (i=0, j=0; j < trig->num_counters &&
i < (trig->counters)->size; i++) {
if (NULL != cntr[i] && if (NULL != cntr[i] &&
ORTE_SUCCESS == orte_gpr_replica_dict_reverse_lookup(&token, cntr[i]->seg, ORTE_SUCCESS == orte_gpr_replica_dict_reverse_lookup(&token, cntr[i]->seg,
(cntr[i]->iptr)->itag)) { (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); (unsigned long) i, (cntr[i]->seg)->name, token);
free(token); free(token);
@ -554,10 +406,225 @@ 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);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
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++;
sprintf(tmp_out, "\t\tSubscription %lu name %s",
(unsigned long) subs[i]->index,
subs[i]->name);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
}
}
free(tmp_out); free(tmp_out);
return; return;
} }
int orte_gpr_replica_dump_subscriptions_fn(orte_buffer_t *buffer)
{
char *tmp_out, *token, *tmp;
size_t i, j, k, m, n, p;
orte_gpr_replica_subscription_t **subs;
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 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 trigger info for the registry */
for (i=0, m=0; m < orte_gpr_replica.num_subs &&
i < (orte_gpr_replica.subscriptions)->size; i++) {
if (NULL != subs[i]) {
m++;
sprintf(tmp_out, "Info for Subscription %lu named %s",
(unsigned long) subs[i]->index, subs[i]->name);
orte_gpr_replica_dump_load_string(buffer, &tmp);
if (subs[i]->active) {
sprintf(tmp_out, "\tSubscription ACTIVE");
} else {
sprintf(tmp_out, "\tSubscription INACTIVE");
}
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);
reqs = (orte_gpr_replica_requestor_t**)(subs[i]->requestors)->addr;
for (j=0, k=0; k < subs[i]->num_requestors &&
j < (subs[i]->requestors)->size; j++) {
if (NULL != reqs[j]) {
k++;
if (NULL == reqs[j]->requestor) {
sprintf(tmp_out, "\t\tRequestor: LOCAL @ subscription id %lu",
(unsigned long) reqs[j]->idtag);
} else {
sprintf(tmp_out, "\t\tRequestor: [%lu,%lu,%lu] @ subscription id %lu",
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 & subs[i]->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_VALUE_CHG");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
} else if (ORTE_GPR_NOTIFY_VALUE_CHG_TO & subs[i]->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_VALUE_CHG_TO");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
} else if (ORTE_GPR_NOTIFY_VALUE_CHG_FRM & subs[i]->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_VALUE_CHG_FRM");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_NOTIFY_DEL_ENTRY & subs[i]->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_DEL_ENTRY");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_NOTIFY_ADD_ENTRY & subs[i]->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_ADD_ENTRY");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_NOTIFY_PRE_EXISTING & subs[i]->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_PRE_EXISTING");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG & subs[i]->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_STARTS_AFTER_TRIG");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_NOTIFY_NO_DATA_WITH_TRIG & subs[i]->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_NO_DATA_WITH_TRIG");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG & subs[i]->action) {
sprintf(tmp_out, "\t\tORTE_GPR_NOTIFY_DELETE_AFTER_TRIG");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
sprintf(tmp_out, "\n\tData covered by this subscription");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
ivals = (orte_gpr_replica_ivalue_t**)(subs[i]->values)->addr;
for (n=0, p=0; p < subs[i]->num_values &&
n < (subs[i]->values)->size; n++) {
if (NULL != ivals[n]) {
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",
(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);
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);
}
if (ORTE_GPR_TOKENS_AND & ivals[n]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_TOKENS_AND\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_OR & ivals[n]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_TOKENS_OR\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_XAND & ivals[n]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_TOKENS_XAND\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_TOKENS_XOR & ivals[n]->addr_mode) {
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)");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
} 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))) {
sprintf(tmp_out, "\t\t\tKey: %s", token);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
free(token);
}
}
}
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);
}
if (ORTE_GPR_KEYS_AND & ivals[n]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_KEYS_AND\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_OR & ivals[n]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_KEYS_OR\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_XAND & ivals[n]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_KEYS_XAND\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_GPR_KEYS_XOR & ivals[n]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_KEYS_XOR\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
} /* if ivals[n] not NULL */
} /* for n */
} /* if subs[i] not NULL */
} /* for i */
free(tmp_out);
return ORTE_SUCCESS;
}
void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer, void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer,
orte_gpr_replica_itagval_t *iptr) orte_gpr_replica_itagval_t *iptr)

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

@ -111,14 +111,11 @@ int orte_gpr_replica_get_nb_fn(orte_gpr_addr_mode_t addr_mode,
/* /*
* Subscribe functions * Subscribe functions
*/ */
int orte_gpr_replica_subscribe_fn(orte_gpr_notify_action_t action, size_t num_subs, int orte_gpr_replica_subscribe_fn(orte_process_name_t *requestor,
size_t num_subs,
orte_gpr_subscription_t **subscriptions, orte_gpr_subscription_t **subscriptions,
size_t num_trigs, size_t num_trigs,
orte_gpr_value_t **trigs, orte_gpr_trigger_t **trigs);
orte_gpr_notify_id_t idtag);
int orte_gpr_replica_unsubscribe_fn(orte_gpr_notify_id_t sub_number);
/* /*
* Diagnostic functions * Diagnostic functions
@ -129,6 +126,8 @@ int orte_gpr_replica_dump_segments_fn(orte_buffer_t *buffer);
int orte_gpr_replica_dump_triggers_fn(orte_buffer_t *buffer); int orte_gpr_replica_dump_triggers_fn(orte_buffer_t *buffer);
int orte_gpr_replica_dump_subscriptions_fn(orte_buffer_t *buffer);
int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer); int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer);
/* /*
@ -139,15 +138,7 @@ int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer);
*/ */
int orte_gpr_replica_release_segment(orte_gpr_replica_segment_t **seg); int orte_gpr_replica_release_segment(orte_gpr_replica_segment_t **seg);
/** int orte_gpr_replica_find_containers(orte_gpr_replica_segment_t *seg,
* Typedef of the orte_gpr_replica_release_segment() function
* signature so that it can be invoked via a function pointer for a
* unit test.
*/
typedef int (*orte_gpr_replica_release_segment_fn_t)
(orte_gpr_replica_segment_t **seg);
int orte_gpr_replica_find_containers(size_t *num_found, orte_gpr_replica_segment_t *seg,
orte_gpr_replica_addr_mode_t addr_mode, orte_gpr_replica_addr_mode_t addr_mode,
orte_gpr_replica_itag_t *taglist, size_t num_tags); orte_gpr_replica_itag_t *taglist, size_t num_tags);
@ -155,16 +146,6 @@ int orte_gpr_replica_create_container(orte_gpr_replica_container_t **cptr,
orte_gpr_replica_segment_t *seg, orte_gpr_replica_segment_t *seg,
size_t num_itags, size_t num_itags,
orte_gpr_replica_itag_t *itags); orte_gpr_replica_itag_t *itags);
/**
* Typedef of the orte_gpr_replica_create_container() function
* signature so that it can be invoked via a function pointer for a
* unit test.
*/
typedef int (*orte_gpr_replica_create_container_fn_t)
(orte_gpr_replica_container_t **cptr,
orte_gpr_replica_segment_t *seg,
size_t num_itags,
orte_gpr_replica_itag_t *itags);
int orte_gpr_replica_release_container(orte_gpr_replica_segment_t *seg, int orte_gpr_replica_release_container(orte_gpr_replica_segment_t *seg,
orte_gpr_replica_container_t *cptr); orte_gpr_replica_container_t *cptr);
@ -174,30 +155,10 @@ int orte_gpr_replica_add_keyval(orte_gpr_replica_itagval_t **ivalptr,
orte_gpr_replica_container_t *cptr, orte_gpr_replica_container_t *cptr,
orte_gpr_keyval_t *kptr); orte_gpr_keyval_t *kptr);
/**
* Typedef of the orte_gpr_replica_add_keyval() function
* signature so that it can be invoked via a function pointer for a
* unit test.
*/
typedef int (*orte_gpr_replica_add_keyval_fn_t)
(orte_gpr_replica_itagval_t **ivalptr,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_container_t *cptr,
orte_gpr_keyval_t *kptr);
int orte_gpr_replica_update_keyval(orte_gpr_replica_segment_t *seg, int orte_gpr_replica_update_keyval(orte_gpr_replica_segment_t *seg,
orte_gpr_replica_container_t *cptr, orte_gpr_replica_container_t *cptr,
orte_gpr_keyval_t *kptr); orte_gpr_keyval_t *kptr);
/**
* Typedef of the orte_gpr_replica_update_keyval() function
* signature so that it can be invoked via a function pointer for a
* unit test.
*/
typedef int (*orte_gpr_replica_update_keyval_fn_t)
(orte_gpr_replica_segment_t *seg,
orte_gpr_replica_container_t *cptr,
orte_gpr_keyval_t *kptr);
int orte_gpr_replica_compare_values(int *cmp, orte_gpr_replica_itagval_t *ival1, int orte_gpr_replica_compare_values(int *cmp, orte_gpr_replica_itagval_t *ival1,
orte_gpr_replica_itagval_t *ival2); orte_gpr_replica_itagval_t *ival2);
@ -205,19 +166,10 @@ int orte_gpr_replica_compare_values(int *cmp, orte_gpr_replica_itagval_t *ival1,
int orte_gpr_replica_purge_itag(orte_gpr_replica_segment_t *seg, int orte_gpr_replica_purge_itag(orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t itag); orte_gpr_replica_itag_t itag);
int orte_gpr_replica_search_container(size_t *cnt, orte_gpr_replica_addr_mode_t addr_mode, int orte_gpr_replica_search_container(orte_gpr_replica_addr_mode_t addr_mode,
orte_gpr_replica_itag_t *itags, size_t num_itags, orte_gpr_replica_itag_t *itags, size_t num_itags,
orte_gpr_replica_container_t *cptr); orte_gpr_replica_container_t *cptr);
/**
* Typedef of the orte_gpr_replica_search_container() function
* signature so that it can be invoked via a function pointer for a
* unit test.
*/
typedef int (*orte_gpr_replica_search_container_fn_t)
(size_t *cnt, orte_gpr_replica_addr_mode_t addr_mode,
orte_gpr_replica_itag_t *itags, size_t num_itags,
orte_gpr_replica_container_t *cptr);
int orte_gpr_replica_get_value(void *value, orte_gpr_replica_itagval_t *ival); int orte_gpr_replica_get_value(void *value, orte_gpr_replica_itagval_t *ival);
@ -235,18 +187,6 @@ bool orte_gpr_replica_check_itag_list(orte_gpr_replica_addr_mode_t mode,
size_t num_itags_entry, size_t num_itags_entry,
orte_gpr_replica_itag_t *entry_itags); orte_gpr_replica_itag_t *entry_itags);
/**
* Typedef of the orte_gpr_replica_check_itag_list() function
* signature so that it can be invoked via a function pointer for a
* unit test.
*/
typedef bool (*orte_gpr_replica_check_itag_list_fn_t)
(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);
int orte_gpr_replica_copy_itag_list(orte_gpr_replica_itag_t **dest, int orte_gpr_replica_copy_itag_list(orte_gpr_replica_itag_t **dest,
orte_gpr_replica_itag_t *src, size_t num_itags); orte_gpr_replica_itag_t *src, size_t num_itags);
@ -256,40 +196,51 @@ void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer,
/* /*
* Trigger Operations * Trigger Operations
*/ */
int orte_gpr_replica_enter_local_subscription(size_t cnt, orte_gpr_subscription_t **subscriptions);
int orte_gpr_replica_enter_local_trigger(size_t cnt, orte_gpr_trigger_t **trigs);
int orte_gpr_replica_record_action(orte_gpr_replica_segment_t *seg, int orte_gpr_replica_record_action(orte_gpr_replica_segment_t *seg,
orte_gpr_replica_container_t *cptr, orte_gpr_replica_container_t *cptr,
orte_gpr_replica_itagval_t *iptr, orte_gpr_replica_itagval_t *iptr,
orte_gpr_replica_action_t action); orte_gpr_replica_action_t action);
int orte_gpr_replica_check_subscriptions(orte_gpr_replica_segment_t *seg); int orte_gpr_replica_check_events(void);
int orte_gpr_replica_check_notify(orte_gpr_replica_triggers_t *trig, int orte_gpr_replica_check_subscription(orte_gpr_replica_subscription_t *sub);
orte_gpr_replica_subscribed_data_t *sub);
bool orte_gpr_replica_check_notify_matches(orte_gpr_replica_subscribed_data_t *sub, bool orte_gpr_replica_check_notify_matches(orte_gpr_value_t *value,
orte_gpr_replica_subscription_t *sub,
orte_gpr_replica_action_taken_t *ptr); orte_gpr_replica_action_taken_t *ptr);
int orte_gpr_replica_check_trig(orte_gpr_replica_triggers_t *trig); int orte_gpr_replica_check_trig(orte_gpr_replica_trigger_t *trig);
int orte_gpr_replica_update_storage_locations(orte_gpr_replica_itagval_t *new_iptr); int orte_gpr_replica_update_storage_locations(orte_gpr_replica_itagval_t *new_iptr);
int orte_gpr_replica_construct_notify_message(orte_gpr_notify_message_t *msg, int orte_gpr_replica_construct_notify_message(orte_gpr_notify_message_t *msg,
orte_gpr_replica_triggers_t *trig, orte_gpr_replica_trigger_t *trig,
orte_gpr_replica_subscribed_data_t *sub, orte_gpr_replica_subscription_t *sub,
orte_gpr_value_t *value); orte_gpr_value_t *value);
int int
orte_gpr_replica_enter_notify_request(orte_gpr_notify_id_t *local_idtag, orte_gpr_replica_register_subscription(orte_gpr_replica_subscription_t **subptr,
orte_process_name_t *requestor, orte_process_name_t *requestor,
orte_gpr_notify_id_t remote_idtag, orte_gpr_subscription_t *subscription);
size_t cnt, orte_gpr_subscription_t **subscriptions);
int int
orte_gpr_replica_remove_notify_request(orte_gpr_notify_id_t local_idtag, orte_gpr_replica_register_trigger(orte_gpr_replica_trigger_t **trigptr,
orte_gpr_notify_id_t *remote_idtag); orte_process_name_t *requestor,
orte_gpr_trigger_t *trigger);
int orte_gpr_replica_register_callback(orte_gpr_replica_triggers_t *trig, int
orte_gpr_replica_subscribed_data_t *sub, orte_gpr_replica_remove_subscription(orte_process_name_t *requestor,
orte_gpr_subscription_id_t id);
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_subscription_t *sub,
orte_gpr_value_t *value); orte_gpr_value_t *value);
int orte_gpr_replica_process_callbacks(void); int orte_gpr_replica_process_callbacks(void);
@ -297,11 +248,12 @@ int orte_gpr_replica_process_callbacks(void);
int orte_gpr_replica_purge_subscriptions(orte_process_name_t *proc); int orte_gpr_replica_purge_subscriptions(orte_process_name_t *proc);
int orte_gpr_replica_add_values_from_registry(orte_gpr_notify_message_t *msg, int orte_gpr_replica_add_values_from_registry(orte_gpr_notify_message_t *msg,
orte_gpr_replica_subscribed_data_t *sptr); orte_gpr_replica_subscription_t *sptr);
int orte_gpr_replica_store_value_in_msg(orte_gpr_notify_id_t cb_num, int orte_gpr_replica_store_value_in_msg(orte_gpr_subscription_id_t id,
orte_gpr_notify_message_t *msg, orte_gpr_notify_message_t *msg,
orte_gpr_value_t *value); size_t cnt,
orte_gpr_value_t **values);
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
} }

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

@ -39,359 +39,334 @@
#include "mca/gpr/replica/communications/gpr_replica_comm.h" #include "mca/gpr/replica/communications/gpr_replica_comm.h"
#include "gpr_replica_fn.h" #include "gpr_replica_fn.h"
static int orte_gpr_replica_add_value_to_datagram(orte_gpr_notify_data_t *data,
size_t cnt, orte_gpr_value_t **values);
int orte_gpr_replica_process_callbacks(void) int orte_gpr_replica_process_callbacks(void)
{ {
orte_gpr_replica_callbacks_t *cb; orte_gpr_replica_callbacks_t *cb;
orte_gpr_replica_notify_msg_list_t *msg;
orte_gpr_notify_data_t **data; orte_gpr_notify_data_t **data;
orte_gpr_replica_subscribed_data_t **sdata; orte_gpr_replica_trigger_t **trigs;
orte_gpr_replica_triggers_t *trig, **trigs; orte_gpr_replica_subscription_t **subs;
bool processed; orte_gpr_replica_requestor_t **reqs;
size_t i, k; orte_gpr_replica_local_subscriber_t *local_sub;
size_t i, j, k, m;
int rc; int rc;
if (orte_gpr_replica_globals.debug) { if (orte_gpr_replica_globals.debug) {
ompi_output(0, "gpr replica: process_callbacks entered"); ompi_output(0, "gpr replica: process_callbacks entered");
} }
/* set flag indicating callbacks being processed */ /* check and set flag indicating callbacks being processed */
if (orte_gpr_replica.processing_callbacks) {
return ORTE_SUCCESS;
}
orte_gpr_replica.processing_callbacks = true; orte_gpr_replica.processing_callbacks = true;
while (NULL != (cb = (orte_gpr_replica_callbacks_t*)ompi_list_remove_last(&orte_gpr_replica.callbacks))) { while (NULL != (cb = (orte_gpr_replica_callbacks_t*)ompi_list_remove_last(&orte_gpr_replica.callbacks))) {
if (NULL == cb->requestor) { /* local callback */ if (NULL == cb->requestor) { /* local callback */
if (orte_gpr_replica_globals.debug) { if (orte_gpr_replica_globals.debug) {
ompi_output(0, "process_callbacks: local"); ompi_output(0, "process_callbacks: local");
} }
/* each callback corresponds to a specific requestor, each of whom can be /* each callback corresponds to a specific requestor
* slated to receive multiple messages. * The message in the callback consists of at least one (and can
* each message in the callback corresponds to a specific subscription request entered * be more) "datagrams" intended for that requestor, each of which
* on the system. Within each subscription request, we can have multiple callback functions * is slated to be returned to a specific
* specified. Hence, we have to loop through all the callback functions that were logged * subscription that corresponds to a specific callback
* for the subscription request to find the one that is to receive each block of data * function on the requestor.
* in the message *
* Since this requestor is "local", we simply execute
* the callbacks ourself.
*/ */
while (NULL != (msg = (orte_gpr_replica_notify_msg_list_t*)ompi_list_remove_first(&(cb->messages)))) { data = (orte_gpr_notify_data_t**)((cb->message)->data);
trig = (orte_gpr_replica_triggers_t*)((orte_gpr_replica.triggers)->addr[(msg->message)->idtag]); for (i=0; i < (cb->message)->cnt; i++) {
if (NULL == trig || NULL == trig->subscribed_data) { /* for each datagram in the message, we need to lookup
ORTE_ERROR_LOG(ORTE_ERR_GPR_DATA_CORRUPT); * the associated subscription id to find the correct
* callback function. This subscription id is in the
* data object itself, and references the local_subscriptions
* array of objects.
*/
local_sub = (orte_gpr_replica_local_subscriber_t*)
(orte_gpr_replica_globals.local_subscriptions)->addr[data[i]->id];
if (NULL == local_sub) { /* this subscription has been deleted - error */
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
goto CLEANUP; goto CLEANUP;
} }
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
data = (msg->message)->data; local_sub->callback(data[i], local_sub->user_tag);
sdata = (orte_gpr_replica_subscribed_data_t**)((trig->subscribed_data)->addr); OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
for (i=0; i < (msg->message)->cnt; i++) {
processed = false;
for (k=0; k < (trig->subscribed_data)->size && !processed; k++) {
if (NULL != sdata[k] && sdata[k]->index == data[i]->cb_num) {
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
sdata[k]->callback(data[i], sdata[k]->user_tag);
OMPI_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
processed = true;
}
}
}
OBJ_RELEASE(msg);
} }
} else { /* remote request - send messages back */
} else { /* remote request - send messages back */
if (orte_gpr_replica_globals.debug) { if (orte_gpr_replica_globals.debug) {
ompi_output(0, "process_callbacks: remote to [%lu,%lu,%lu]", ompi_output(0, "process_callbacks: remote to [%lu,%lu,%lu]",
ORTE_NAME_ARGS(cb->requestor)); ORTE_NAME_ARGS(cb->requestor));
} }
orte_gpr_replica_remote_notify(cb->requestor, &(cb->messages)); orte_gpr_replica_remote_notify(cb->requestor, cb->message);
} }
CLEANUP: CLEANUP:
OBJ_RELEASE(cb); OBJ_RELEASE(cb);
} }
/* all callbacks processed - indicate list is open */
orte_gpr_replica.processing_callbacks = false;
/* cleanup any one-shot triggers that fired */ /* cleanup any one-shot triggers that fired */
trigs = (orte_gpr_replica_triggers_t**)((orte_gpr_replica.triggers)->addr); trigs = (orte_gpr_replica_trigger_t**)((orte_gpr_replica.triggers)->addr);
for (i=0; i < (orte_gpr_replica.triggers)->size; i++) { for (i=0, k=0, m=0; k < orte_gpr_replica.num_trigs &&
if (NULL != trigs[i] && trigs[i]->one_shot_fired) { i < (orte_gpr_replica.triggers)->size; i++) {
/* if no notify actions were specified to stick around after if (NULL != trigs[i]) {
* the trigger, then simply remove the trigger. Otherwise, k++;
* clear the trigger flags and leave the notify flags alone if (trigs[i]->one_shot_fired) {
*/
if (ORTE_GPR_NOTIFY_ANY & trigs[i]->action) {
trigs[i]->action = trigs[i]->action & ORTE_GPR_NOTIFY_ANY;
} else {
k = trigs[i]->index;
OBJ_RELEASE(trigs[i]); OBJ_RELEASE(trigs[i]);
if (ORTE_SUCCESS != (rc = orte_pointer_array_set_item(orte_gpr_replica.triggers, orte_pointer_array_set_item(orte_gpr_replica.triggers, i, NULL);
k, NULL))) { m++;
ORTE_ERROR_LOG(rc); }
return rc; }
}
orte_gpr_replica.num_trigs -= m;
/* cleanup any subscriptions that are supposed to be
* removed based on a trigger having fired
*/
subs = (orte_gpr_replica_subscription_t**)(orte_gpr_replica.subscriptions)->addr;
for (i=0, k=0; k < orte_gpr_replica.num_subs &&
i < (orte_gpr_replica.subscriptions)->size; i++) {
if (NULL != subs[i]) {
k++;
if (subs[i]->cleanup) {
reqs = (orte_gpr_replica_requestor_t**)(subs[i]->requestors)->addr;
for (j=0, m=0; NULL != subs[i] &&
m < subs[i]->num_requestors &&
j < (subs[i]->requestors)->size; j++) {
if (NULL != reqs[j]) {
m++;
if (ORTE_SUCCESS != (rc =
orte_gpr_replica_remove_subscription(reqs[j]->requestor, reqs[j]->idtag))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
} }
} }
} }
} }
/* all callbacks processed - indicate list is open */
orte_gpr_replica.processing_callbacks = false;
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
int orte_gpr_replica_register_callback(orte_gpr_replica_triggers_t *trig, int orte_gpr_replica_register_callback(orte_gpr_replica_subscription_t *sub,
orte_gpr_replica_subscribed_data_t *sub,
orte_gpr_value_t *value) orte_gpr_value_t *value)
{ {
orte_gpr_replica_callbacks_t *cb; orte_gpr_replica_callbacks_t *cb;
orte_gpr_replica_notify_msg_list_t *msg; 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;
bool cleanup_reqd;
int rc; int rc;
/* see if a callback has already been requested for this requestor */ /* The data to be returned will be the same for all requestors
for (cb = (orte_gpr_replica_callbacks_t*)ompi_list_get_first(&(orte_gpr_replica.callbacks)); * on this subscription. First, let's get the data (if it hasn't
cb != (orte_gpr_replica_callbacks_t*)ompi_list_get_end(&(orte_gpr_replica.callbacks)); * already been provided) so we have it ready to be added to
cb = (orte_gpr_replica_callbacks_t*)ompi_list_get_next(cb)) { * the callback
if ((NULL == trig->requestor && NULL == cb->requestor) /* both local */ */
|| ((NULL != trig->requestor && NULL != cb->requestor) &&
0 == orte_ns.compare(ORTE_NS_CMP_ALL, trig->requestor, cb->requestor))) { /* same remote requestor - add to existing callback */ /* check to see if value provided - if so, we'll just use it */
/* check to see if we already have something for this trigger - if so, add to it */ if (NULL != value) {
for (msg = (orte_gpr_replica_notify_msg_list_t*)ompi_list_get_first(&(cb->messages)); values = &value;
msg != (orte_gpr_replica_notify_msg_list_t*)ompi_list_get_end(&(cb->messages)); cnt = 1;
msg = (orte_gpr_replica_notify_msg_list_t*)ompi_list_get_next(msg)) { cleanup_reqd = false;
if ((msg->message)->idtag == trig->index) { /* same trigger - add to it */ } else {
if (orte_gpr_replica_globals.debug) { /* value not provided - get the data off the registry. since a
ompi_output(0, "[%lu,%lu,%lu] process_trig: adding message for requestor [%lu,%lu,%lu] for idtag %lu\n", * subscription can have multiple data sources specified, we
ORTE_NAME_ARGS(orte_process_info.my_name), ORTE_NAME_ARGS(cb->requestor), (unsigned long)trig->index); * have to loop through those sources, constructing an aggregated
} * array of data values that we can work with in composing the
if (ORTE_SUCCESS != (rc = * final message
orte_gpr_replica_construct_notify_message(msg->message, */
trig, sub, value))) { ivals = (orte_gpr_replica_ivalue_t**)(sub->values)->addr;
ORTE_ERROR_LOG(rc); cnt = 0;
} values = NULL;
return rc; for (i=0, j=0; j < sub->num_values &&
} i < (sub->values)->size; i++) {
} if (NULL != ivals[i]) {
/* same requestor, different trigger - add another message to callback */ j++;
msg = OBJ_NEW(orte_gpr_replica_notify_msg_list_t); num_tokens = orte_value_array_get_size(&(ivals[i]->tokentags));
if (NULL == msg) { 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];
}
/* update the count */
cnt += interim;
}
}
cleanup_reqd = true;
}
/* We now have the data to be sent to each requestor attached
* to this subscription.
* Each subscription that was placed on the system has an associated
* structure containing the process name and array of callback info where
* data is to be returned. For remote processes, the callback
* info is omitted and a subscription id is recorded - this tells
* 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
* 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.
*/
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++;
/* see if a callback has already been registered for this process */
for (cb = (orte_gpr_replica_callbacks_t*)ompi_list_get_first(&(orte_gpr_replica.callbacks));
cb != (orte_gpr_replica_callbacks_t*)ompi_list_get_end(&(orte_gpr_replica.callbacks));
cb = (orte_gpr_replica_callbacks_t*)ompi_list_get_next(cb)) {
if ((NULL == reqs[i]->requestor && NULL == cb->requestor) ||
((NULL != reqs[i]->requestor && NULL != cb->requestor) &&
(0 == orte_ns.compare(ORTE_NS_CMP_ALL,
reqs[i]->requestor,
cb->requestor)))) {
/* okay, a callback has been registered to send data to this
* process - add to that message
*/
goto PROCESS;
}
}
/* this is going to somebody new - create a new callback
* for this requestor
*/
cb = OBJ_NEW(orte_gpr_replica_callbacks_t);
if (NULL == cb) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; rc = ORTE_ERR_OUT_OF_RESOURCE;
} goto CLEANUP;
ompi_list_append(&cb->messages, &msg->item); }
if (NULL == reqs[i]->requestor) {
cb->requestor = NULL;
} else {
if (ORTE_SUCCESS != (rc = orte_ns.copy_process_name(&(cb->requestor), reqs[i]->requestor))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
}
ompi_list_append(&orte_gpr_replica.callbacks, &cb->item);
/* construct the message */ /* construct the message */
msg->message = OBJ_NEW(orte_gpr_notify_message_t); cb->message = OBJ_NEW(orte_gpr_notify_message_t);
if (NULL == msg->message) { if (NULL == cb->message) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
} }
if (NULL == trig->requestor) { PROCESS:
(msg->message)->idtag = trig->index; /* okay, now we have a message going to the requestor. We need to
} else { * store the values in the notify_data structure corresponding to this
(msg->message)->idtag = trig->remote_idtag; * subscription id, combining data where the id's match
} */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_store_value_in_msg(reqs[i]->idtag,
if (ORTE_SUCCESS != (rc = cb->message, cnt, values))) {
orte_gpr_replica_construct_notify_message(msg->message,
trig, sub, value))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
goto CLEANUP;
} }
return rc; } /* if NULL */
}
}
/* this is going to somebody new - create a new callback for this requestor */
cb = OBJ_NEW(orte_gpr_replica_callbacks_t);
if (NULL == cb) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (NULL == trig->requestor) { /* local request - queue local callback */
cb->requestor = NULL;
if (orte_gpr_replica_globals.debug) {
ompi_output(0, "[%lu,%lu,%lu] process_trig: queueing local callback for idtag %lu\n",
ORTE_NAME_ARGS(orte_process_info.my_name), (unsigned long)trig->index);
}
} else { /* remote request - queue remote callback */
if (ORTE_SUCCESS != (rc = orte_ns.copy_process_name(&(cb->requestor), trig->requestor))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(cb);
return rc;
}
if (orte_gpr_replica_globals.debug) {
ompi_output(0, "[%lu,%lu,%lu] process_trig: queueing callback for [%lu,%lu,%lu] using remoteid %lu\n",
ORTE_NAME_ARGS(orte_process_info.my_name), ORTE_NAME_ARGS(cb->requestor),
(unsigned long)trig->remote_idtag);
}
}
ompi_list_append(&orte_gpr_replica.callbacks, &cb->item);
/* construct the message list item */
msg = OBJ_NEW(orte_gpr_replica_notify_msg_list_t);
if (NULL == msg) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* construct the message */
msg->message = OBJ_NEW(orte_gpr_notify_message_t);
if (NULL == msg->message) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (NULL == trig->requestor) {
(msg->message)->idtag = trig->index;
} else {
(msg->message)->idtag = trig->remote_idtag;
}
ompi_list_append(&cb->messages, &msg->item);
if (ORTE_SUCCESS != (rc =
orte_gpr_replica_construct_notify_message(msg->message,
trig, sub, value))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(cb);
return rc;
}
if (orte_gpr_replica_globals.debug) {
ompi_output(0, "[%lu,%lu,%lu] gpr replica-process_trig: complete",
ORTE_NAME_ARGS(orte_process_info.my_name));
}
return ORTE_SUCCESS;
}
int orte_gpr_replica_construct_notify_message(orte_gpr_notify_message_t *msg,
orte_gpr_replica_triggers_t *trig,
orte_gpr_replica_subscribed_data_t *sub,
orte_gpr_value_t *value)
{
int rc=ORTE_SUCCESS;
orte_gpr_replica_subscribed_data_t **sptr;
size_t i;
/* if we don't have data, just return */
if (0 >= trig->num_subscribed_data && NULL == value) {
return ORTE_SUCCESS;
}
/* check to see if value provided - if so, use it */
if (NULL != value) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_store_value_in_msg(sub->index,
msg, value))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
/* otherwise, go get values off of registry and add them to the data object */
sptr = (orte_gpr_replica_subscribed_data_t**)((trig->subscribed_data)->addr);
for (i=0; i < (trig->subscribed_data)->size; i++) {
if (NULL != sptr[i]) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_add_values_from_registry(msg, sptr[i]))) {
ORTE_ERROR_LOG(rc);
return rc;
}
} /* if sptr not NULL */
} /* for i */ } /* for i */
return ORTE_SUCCESS; CLEANUP:
if (cleanup_reqd) {
for (i=0; i < cnt; i++) OBJ_RELEASE(values[i]);
if (NULL != values) free(values);
}
return rc;
} }
int orte_gpr_replica_add_values_from_registry(orte_gpr_notify_message_t *msg, int orte_gpr_replica_store_value_in_msg(orte_gpr_subscription_id_t id,
orte_gpr_replica_subscribed_data_t *sptr)
{
size_t i, j, num_tokens, num_keys, cnt;
int rc;
orte_gpr_value_t **values = NULL;
/* get the data off the registry */
num_tokens = orte_value_array_get_size(&(sptr->tokentags));
num_keys = orte_value_array_get_size(&(sptr->keytags));
if (orte_gpr_replica_globals.debug) {
ompi_output(0, "add_values: performing a get");
}
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_fn(sptr->addr_mode, sptr->seg,
ORTE_VALUE_ARRAY_GET_BASE(&(sptr->tokentags), orte_gpr_replica_itag_t),
num_tokens,
ORTE_VALUE_ARRAY_GET_BASE(&(sptr->keytags), orte_gpr_replica_itag_t),
num_keys,
&cnt, &values))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (orte_gpr_replica_globals.debug) {
ompi_output(0, "add_values: get returned %d values", cnt);
for (i=0; i < cnt; i++) {
ompi_output(0, "Data for value %d from segment %s\nTokens:", i, values[i]->segment);
for (j=0; j < values[i]->num_tokens; j++) {
ompi_output(0, "\ttoken num: %d\tToken: %s", j, values[i]->tokens[j]);
}
ompi_output(0, "\tGot %d keyvals:", values[i]->cnt);
/* for (j=0; j < values[i]->cnt; j++) {
ompi_output(0, "\tValue num: %d\tKey: %s", j, (values[i]->keyvals[j])->key);
orte_gpr_base_dump_keyval_value(values[i]->keyvals[j], 0);
}
*/
}
}
/* store these values in the notify_data structure, combining data
* where containers match
*/
for (i=0; i < cnt; i++) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_store_value_in_msg(sptr->index,
msg, values[i]))) {
ORTE_ERROR_LOG(rc);
for (j=i; j < cnt; j++) OBJ_RELEASE(values[j]);
free(values);
return rc;
}
OBJ_RELEASE(values[i]);
} /* for i */
if (NULL != values) {
free(values);
}
return ORTE_SUCCESS;
}
int orte_gpr_replica_store_value_in_msg(orte_gpr_notify_id_t cb_num,
orte_gpr_notify_message_t *msg, orte_gpr_notify_message_t *msg,
orte_gpr_value_t *value) size_t cnt,
orte_gpr_value_t **values)
{ {
size_t j, k, n, m, matches, num_tokens; size_t j, k, n, index;
int rc; int rc;
orte_gpr_value_t **data_values; orte_gpr_value_t **vals;
orte_gpr_keyval_t **kptr; orte_gpr_keyval_t **kptr;
orte_gpr_notify_data_t **data;
if (NULL == msg->data) { /* first data item on message */ /* find the datagram corresponding to the provided subscription id */
if (NULL == msg->data) { /* first datagram on message */
msg->data = (orte_gpr_notify_data_t**)malloc(sizeof(orte_gpr_notify_data_t*)); msg->data = (orte_gpr_notify_data_t**)malloc(sizeof(orte_gpr_notify_data_t*));
if (NULL == msg->data) { if (NULL == msg->data) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
data = &(msg->data[0]); /* need to assign location */ index = 0; /* need to assign location */
msg->cnt = 1; msg->cnt = 1;
} else { } else {
/* check to see if this data is going to the same callback as /* check to see if this data is going to the same callback as
* any prior data on the message. if so, then we add those keyvals * any prior data on the message. if so, then we add the values
* to the existing data structure. if not, then we realloc to * to that existing data structure. if not, then we realloc to
* establish a new data structure and store the data there * establish a new data structure and store the data there
*/ */
for (k=0; k < msg->cnt; k++) { for (k=0; k < msg->cnt; k++) {
if (msg->data[k]->cb_num == cb_num) { /* going to the same place */ if (msg->data[k]->id == id) { /* going to the same place */
data = &(msg->data[k]); if (ORTE_SUCCESS != (rc =
goto MOVEON; orte_gpr_replica_add_value_to_datagram(
msg->data[k], cnt, values))) {
ORTE_ERROR_LOG(rc);
}
return rc;
} }
} }
/* no prior matching data found, so add another data location to the message */ /* no prior matching data found, so add another data location to the message */
@ -400,140 +375,220 @@ int orte_gpr_replica_store_value_in_msg(orte_gpr_notify_id_t cb_num,
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
data = &(msg->data[msg->cnt]); index = msg->cnt;
(msg->cnt)++; (msg->cnt)++;
} }
*data = OBJ_NEW(orte_gpr_notify_data_t); msg->data[index] = OBJ_NEW(orte_gpr_notify_data_t);
if (NULL == *data) { if (NULL == msg->data[index]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
/* store the callback_number, addressing mode, and name /* store the callback id */
* of the segment this data came from msg->data[index]->id = id;
*/
(*data)->cb_num = cb_num; /* since this datagram is new, allocate the required data locations */
(*data)->addr_mode = value->addr_mode; msg->data[index]->cnt = cnt;
(*data)->segment = strdup(value->segment); if (0 == cnt) { /* no data to attach */
if (NULL == (*data)->segment) { return ORTE_SUCCESS;
}
msg->data[index]->values = (orte_gpr_value_t**)malloc(cnt * sizeof(orte_gpr_value_t*));
if (NULL == msg->data[index]->values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
/* transfer the values to the datagram */
MOVEON: vals = msg->data[index]->values;
/* add the values to the data object */ for (j=0; j < cnt; j++) {
if (NULL == (*data)->values) { /* first value on the structure */ vals[j] = OBJ_NEW(orte_gpr_value_t);
(*data)->values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*)); if (NULL == vals[j]) {
if (NULL == (*data)->values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
data_values = &((*data)->values[0]); /* need to assign location */ /* record the addressing mode */
(*data)->cnt = 1; vals[j]->addr_mode = values[j]->addr_mode;
} else { /* record the segment these values came from */
vals[j]->segment = strdup(values[j]->segment);
if (NULL == (vals[j]->segment)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* record the tokens describing the container */
vals[j]->num_tokens = values[j]->num_tokens;
if (0 == values[j]->num_tokens) {
/* this is an illegal case - the tokens here describe
* the container from which this data was obtained. The
* container MUST have tokens that describe it
*/
ORTE_ERROR_LOG(ORTE_ERR_GPR_DATA_CORRUPT);
return ORTE_ERR_GPR_DATA_CORRUPT;
}
vals[j]->tokens = (char **)malloc(values[j]->num_tokens *
sizeof(char*));
if (NULL == vals[j]->tokens) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
for (n=0; n < values[j]->num_tokens; n++) {
vals[j]->tokens[n] = strdup(values[j]->tokens[n]);
if (NULL == vals[j]->tokens[n]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
}
/* record the keyvals */
vals[j]->keyvals = (orte_gpr_keyval_t**)malloc(values[j]->cnt *
sizeof(orte_gpr_keyval_t*));
if (NULL == vals[j]->keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
vals[j]->cnt = values[j]->cnt;
kptr = vals[j]->keyvals;
for (n=0; n < values[j]->cnt; n++) {
kptr[n] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == kptr[n]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
kptr[n]->key = strdup((values[j]->keyvals[n])->key);
if (NULL == kptr[n]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
kptr[n]->type = (values[j]->keyvals[n])->type;
if (ORTE_SUCCESS != (rc = orte_gpr_base_xfer_payload(
&(kptr[n]->value), &((values[j]->keyvals[n])->value),
(values[j]->keyvals[n])->type))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
}
return ORTE_SUCCESS;
}
static int orte_gpr_replica_add_value_to_datagram(orte_gpr_notify_data_t *data,
size_t cnt, orte_gpr_value_t **values)
{
size_t i, j, k, n, m, index, matches, num_tokens;
int rc;
orte_gpr_value_t *value;
orte_gpr_keyval_t **kptr;
for (i=0; i < cnt; i++) {
value = values[i];
/* check to see if this value is from the same container /* check to see if this value is from the same container
* as some prior one. if so, then we add those itagvals * as some prior one. if so, then we add those itagvals
* to the existing value structure. if not, then we realloc to * to the existing value structure. if not, then we realloc to
* establish a new value structure and store the data there * establish a new value structure and store the data there
*/ */
for (k=0; k < (*data)->cnt; k++) { for (k=0; k < data->cnt; k++) {
matches = 0; matches = 0;
num_tokens = (*data)->values[k]->num_tokens; num_tokens = data->values[k]->num_tokens;
if (num_tokens == value->num_tokens) { /* must have same number or can't match */ if (num_tokens == value->num_tokens) { /* must have same number or can't match */
for (j=0; j < num_tokens; j++) { for (j=0; j < num_tokens; j++) {
for (m=0; m < num_tokens; m++) { for (m=0; m < num_tokens; m++) {
if (0 == strcmp(((*data)->values[k])->tokens[j], value->tokens[m])) { if (0 == strcmp((data->values[k])->tokens[j], value->tokens[m])) {
matches++; matches++;
} }
} }
if (num_tokens == matches) { /* from same container - just add keyvals to it */ if (num_tokens == matches) { /* from same container - just add keyvals to it */
data_values = &((*data)->values[k]); index = k;
goto MOVEON2; goto ADDKVALS;
} }
} }
} }
} }
/* no prior matching data found, so add another value location to the object */ /* no prior matching data found, so add another value structure to the object */
(*data)->values = (orte_gpr_value_t**)realloc((*data)->values, ((*data)->cnt + 1)*sizeof(orte_gpr_value_t*)); data->values = (orte_gpr_value_t**)realloc(data->values, (data->cnt + 1)*sizeof(orte_gpr_value_t*));
if (NULL == (*data)->values) { if (NULL == data->values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
data_values = &((*data)->values[(*data)->cnt]); index = data->cnt;
((*data)->cnt)++; (data->cnt)++;
}
*data_values = OBJ_NEW(orte_gpr_value_t); data->values[index] = OBJ_NEW(orte_gpr_value_t);
if (NULL == *data_values) { if (NULL == data->values[index]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
/* record the addressing mode */ /* record the addressing mode */
(*data_values)->addr_mode = value->addr_mode; data->values[index]->addr_mode = value->addr_mode;
/* record the segment these values came from */ /* record the segment these values came from */
(*data_values)->segment = strdup(value->segment); data->values[index]->segment = strdup(value->segment);
if (NULL == ((*data_values)->segment)) { if (NULL == data->values[index]->segment) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
/* record the tokens describing the container */ /* record the tokens describing the container */
(*data_values)->num_tokens = value->num_tokens; data->values[index]->num_tokens = value->num_tokens;
if (0 < value->num_tokens) { /* could be a wildcard case */ if (0 == value->num_tokens) {
(*data_values)->tokens = (char **)malloc(value->num_tokens * sizeof(char*)); /* this is an illegal case - the tokens here describe
if (NULL == (*data_values)->tokens) { * the container from which this data was obtained. The
* container MUST have tokens that describe it
*/
ORTE_ERROR_LOG(ORTE_ERR_GPR_DATA_CORRUPT);
return ORTE_ERR_GPR_DATA_CORRUPT;
}
data->values[index]->tokens = (char **)malloc(value->num_tokens * sizeof(char*));
if (NULL == data->values[index]->tokens) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
for (n=0; n < value->num_tokens; n++) { for (n=0; n < value->num_tokens; n++) {
(*data_values)->tokens[n] = strdup(value->tokens[n]); data->values[index]->tokens[n] = strdup(value->tokens[n]);
if (NULL == (*data_values)->tokens[n]) { if (NULL == data->values[index]->tokens[n]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
} }
}
MOVEON2: ADDKVALS:
/* record the value to be returned */ /* transfer the data in the value to be returned */
if (0 < (*data_values)->cnt) { /* already have some data here, so add to the space */ if (0 < data->values[index]->cnt) { /* already have some data here, so add to the space */
n = (*data_values)->cnt + value->cnt; n = data->values[index]->cnt + value->cnt;
(*data_values)->keyvals = (orte_gpr_keyval_t**) data->values[index]->keyvals = (orte_gpr_keyval_t**)
realloc((*data_values)->keyvals, n * sizeof(orte_gpr_keyval_t*)); realloc(data->values[index]->keyvals, n * sizeof(orte_gpr_keyval_t*));
if (NULL == (*data_values)->keyvals) { if (NULL == data->values[index]->keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
}
kptr = &(data->values[index]->keyvals[data->values[index]->cnt]);
data->values[index]->cnt = n;
} else {
data->values[index]->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
if (NULL == data->values[index]->keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
data->values[index]->cnt = value->cnt;
kptr = data->values[index]->keyvals;
} }
kptr = &((*data_values)->keyvals[(*data_values)->cnt]);
(*data_values)->cnt = n; for (n=0; n < value->cnt; n++) {
} else { kptr[n] = OBJ_NEW(orte_gpr_keyval_t);
(*data_values)->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*)); if (NULL == kptr[n]) {
if (NULL == (*data_values)->keyvals) { ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); return ORTE_ERR_OUT_OF_RESOURCE;
return ORTE_ERR_OUT_OF_RESOURCE; }
kptr[n]->key = strdup((value->keyvals[n])->key);
if (NULL == kptr[n]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
kptr[n]->type = (value->keyvals[n])->type;
if (ORTE_SUCCESS != (rc = orte_gpr_base_xfer_payload(
&(kptr[n]->value), &((value->keyvals[n])->value),
(value->keyvals[n])->type))) {
ORTE_ERROR_LOG(rc);
return rc;
}
} }
(*data_values)->cnt = value->cnt;
kptr = (*data_values)->keyvals;
} }
for (n=0; n < value->cnt; n++) {
kptr[n] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == kptr[n]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
kptr[n]->key = strdup((value->keyvals[n])->key);
if (NULL == kptr[n]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
kptr[n]->type = (value->keyvals[n])->type;
if (ORTE_SUCCESS != (rc = orte_gpr_base_xfer_payload(
&(kptr[n]->value), &((value->keyvals[n])->value),
(value->keyvals[n])->type))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }

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

@ -134,7 +134,7 @@ int orte_gpr_replica_put_fn(orte_gpr_addr_mode_t addr_mode,
bool overwrite; bool overwrite;
char *tmp=NULL; char *tmp=NULL;
int rc; int rc;
size_t i, j, num_found; size_t i, j, k;
if (orte_gpr_replica_globals.debug) { if (orte_gpr_replica_globals.debug) {
ompi_output(0, "[%lu,%lu,%lu] gpr replica: put entered on segment %s\nValues:", ompi_output(0, "[%lu,%lu,%lu] gpr replica: put entered on segment %s\nValues:",
@ -164,18 +164,18 @@ int orte_gpr_replica_put_fn(orte_gpr_addr_mode_t addr_mode,
} }
/* find the specified container(s) */ /* find the specified container(s) */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_containers(&num_found, seg, tok_mode, if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_containers(seg, tok_mode,
token_itags, num_tokens))) { token_itags, num_tokens))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
if (NULL == token_itags && 0 == num_found) { /* wildcard tokens but nothing found */ if (NULL == token_itags && 0 == orte_gpr_replica_globals.num_srch_cptr) { /* wildcard tokens but nothing found */
/* no ERROR_LOG entry created as this is not a system failure */ /* no ERROR_LOG entry created as this is not a system failure */
return ORTE_ERR_NOT_FOUND; return ORTE_ERR_NOT_FOUND;
} }
if (0 == num_found) { /* existing container not found - create one */ if (0 == orte_gpr_replica_globals.num_srch_cptr) { /* existing container not found - create one */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_create_container(&cptr2, seg, if (ORTE_SUCCESS != (rc = orte_gpr_replica_create_container(&cptr2, seg,
num_tokens, token_itags))) { num_tokens, token_itags))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
@ -199,14 +199,16 @@ int orte_gpr_replica_put_fn(orte_gpr_addr_mode_t addr_mode,
} else { /* otherwise, go through list of containers. For each one, } else { /* otherwise, go through list of containers. For each one,
see if entry already exists in container - overwrite if allowed */ see if entry already exists in container - overwrite if allowed */
cptr = (orte_gpr_replica_container_t**)(orte_gpr_replica_globals.srch_cptr)->addr; cptr = (orte_gpr_replica_container_t**)(orte_gpr_replica_globals.srch_cptr)->addr;
for (j=0; j < (orte_gpr_replica_globals.srch_cptr)->size; j++) { for (j=0, k=0; k < orte_gpr_replica_globals.num_srch_cptr &&
j < (orte_gpr_replica_globals.srch_cptr)->size; j++) {
if (NULL != cptr[j]) { if (NULL != cptr[j]) {
k++;
for (i=0; i < cnt; i++) { /* for each provided keyval */ for (i=0; i < cnt; i++) { /* for each provided keyval */
if (ORTE_SUCCESS == orte_gpr_replica_create_itag(&itag, seg, keyvals[i]->key) && if (ORTE_SUCCESS == orte_gpr_replica_create_itag(&itag, seg, keyvals[i]->key) &&
ORTE_SUCCESS == orte_gpr_replica_search_container(&num_found, ORTE_SUCCESS == orte_gpr_replica_search_container(
ORTE_GPR_REPLICA_OR, ORTE_GPR_REPLICA_OR,
&itag, 1, cptr[j])) { &itag, 1, cptr[j])) {
if (0 < num_found) { if (0 < orte_gpr_replica_globals.num_srch_ival) {
/* this key already exists - overwrite, if permission given /* this key already exists - overwrite, if permission given
* else add this keyval to the container as a new entry * else add this keyval to the container as a new entry
*/ */
@ -277,7 +279,7 @@ int orte_gpr_replica_get_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_keyval_t **kptr; orte_gpr_keyval_t **kptr;
orte_gpr_replica_addr_mode_t tokmode, keymode; orte_gpr_replica_addr_mode_t tokmode, keymode;
int rc; int rc;
size_t i, j, num_found; size_t i, j, k, m;
char *token; char *token;
if (orte_gpr_replica_globals.debug) { if (orte_gpr_replica_globals.debug) {
@ -313,6 +315,7 @@ int orte_gpr_replica_get_fn(orte_gpr_addr_mode_t addr_mode,
OBJ_CONSTRUCT(&get_list, ompi_list_t); OBJ_CONSTRUCT(&get_list, ompi_list_t);
*cnt = 0; *cnt = 0;
*values = NULL; *values = NULL;
tokmode = 0x004f & addr_mode; tokmode = 0x004f & addr_mode;
if (0x00 == tokmode) { /* default token addressing mode to AND */ if (0x00 == tokmode) { /* default token addressing mode to AND */
tokmode = ORTE_GPR_REPLICA_AND; tokmode = ORTE_GPR_REPLICA_AND;
@ -323,7 +326,7 @@ int orte_gpr_replica_get_fn(orte_gpr_addr_mode_t addr_mode,
} }
/* find all containers that meet search criteria for tokens */ /* find all containers that meet search criteria for tokens */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_containers(&num_found, seg, tokmode, if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_containers(seg, tokmode,
tokentags, num_tokens))) { tokentags, num_tokens))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&get_list); OBJ_DESTRUCT(&get_list);
@ -331,7 +334,7 @@ int orte_gpr_replica_get_fn(orte_gpr_addr_mode_t addr_mode,
} }
/* if nothing found, then can return */ /* if nothing found, then can return */
if (0 == num_found) { if (0 == orte_gpr_replica_globals.num_srch_cptr) {
OBJ_DESTRUCT(&get_list); OBJ_DESTRUCT(&get_list);
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
@ -340,29 +343,35 @@ int orte_gpr_replica_get_fn(orte_gpr_addr_mode_t addr_mode,
* subject to specified mode. Collect the results on get_list * subject to specified mode. Collect the results on get_list
*/ */
cptr = (orte_gpr_replica_container_t**)((orte_gpr_replica_globals.srch_cptr)->addr); cptr = (orte_gpr_replica_container_t**)((orte_gpr_replica_globals.srch_cptr)->addr);
for (i=0; i < (orte_gpr_replica_globals.srch_cptr)->size; i++) { for (i=0, k=0; k < orte_gpr_replica_globals.num_srch_cptr &&
if ((NULL != cptr[i]) && i < (orte_gpr_replica_globals.srch_cptr)->size; i++) {
(ORTE_SUCCESS == orte_gpr_replica_search_container(&num_found, keymode, if (NULL != cptr[i]) {
keytags, num_keys, cptr[i])) && 0 < num_found) { k++;
gptr = OBJ_NEW(orte_gpr_replica_get_list_t); if (ORTE_SUCCESS == orte_gpr_replica_search_container(keymode,
gptr->cptr = cptr[i]; keytags, num_keys, cptr[i]) &&
iptr = (orte_gpr_replica_itagval_t**)((orte_gpr_replica_globals.srch_ival)->addr); 0 < orte_gpr_replica_globals.num_srch_ival) {
for (j=0; j < (orte_gpr_replica_globals.srch_ival)->size; j++) { gptr = OBJ_NEW(orte_gpr_replica_get_list_t);
if (NULL != iptr[j]) { gptr->cptr = cptr[i];
ival_list = OBJ_NEW(orte_gpr_replica_ival_list_t); iptr = (orte_gpr_replica_itagval_t**)((orte_gpr_replica_globals.srch_ival)->addr);
ival_list->itag = iptr[j]->itag; for (j=0, m=0; m < orte_gpr_replica_globals.num_srch_ival &&
ival_list->type = iptr[j]->type; j < (orte_gpr_replica_globals.srch_ival)->size; j++) {
if (ORTE_SUCCESS != (rc = orte_gpr_base_xfer_payload( if (NULL != iptr[j]) {
&(ival_list->value), &(iptr[j]->value), iptr[j]->type))) { m++;
ORTE_ERROR_LOG(rc); ival_list = OBJ_NEW(orte_gpr_replica_ival_list_t);
OBJ_RELEASE(ival_list); ival_list->itag = iptr[j]->itag;
return rc; ival_list->type = iptr[j]->type;
if (ORTE_SUCCESS != (rc = orte_gpr_base_xfer_payload(
&(ival_list->value), &(iptr[j]->value), iptr[j]->type))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(ival_list);
return rc;
}
ompi_list_append(gptr->ival_list, &ival_list->item);
} }
ompi_list_append(gptr->ival_list, &ival_list->item);
} }
ompi_list_append(&get_list, &gptr->item);
(*cnt)++; /* update number of containers that had something found */
} }
ompi_list_append(&get_list, &gptr->item);
(*cnt)++; /* update number of containers that had something found */
} }
} }

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

@ -25,6 +25,7 @@
#include "orte_config.h" #include "orte_config.h"
#include "class/ompi_object.h"
#include "util/output.h" #include "util/output.h"
#include "util/argv.h" #include "util/argv.h"
#include "mca/errmgr/errmgr.h" #include "mca/errmgr/errmgr.h"
@ -33,28 +34,32 @@
#include "gpr_replica_fn.h" #include "gpr_replica_fn.h"
int orte_gpr_replica_find_containers(size_t *num_found, orte_gpr_replica_segment_t *seg, int orte_gpr_replica_find_containers(orte_gpr_replica_segment_t *seg,
orte_gpr_replica_addr_mode_t addr_mode, orte_gpr_replica_addr_mode_t addr_mode,
orte_gpr_replica_itag_t *taglist, size_t num_tags) orte_gpr_replica_itag_t *taglist, size_t num_tags)
{ {
orte_gpr_replica_container_t **cptr; orte_gpr_replica_container_t **cptr;
size_t i, index; size_t i, j, index;
/* ensure the search array is clear */ /* ensure the search array is clear */
orte_pointer_array_clear(orte_gpr_replica_globals.srch_cptr); orte_pointer_array_clear(orte_gpr_replica_globals.srch_cptr);
*num_found = 0; orte_gpr_replica_globals.num_srch_cptr = 0;
cptr = (orte_gpr_replica_container_t**)((seg->containers)->addr); cptr = (orte_gpr_replica_container_t**)((seg->containers)->addr);
for (i=0; i < (seg->containers)->size; i++) { for (i=0, j=0; j < seg->num_containers &&
if (NULL != cptr[i] && orte_gpr_replica_check_itag_list(addr_mode, i < (seg->containers)->size; i++) {
if (NULL != cptr[i]) {
j++;
if (orte_gpr_replica_check_itag_list(addr_mode,
num_tags, taglist, num_tags, taglist,
cptr[i]->num_itags, cptr[i]->itags)) { cptr[i]->num_itags, cptr[i]->itags)) {
if (0 > orte_pointer_array_add(&index, orte_gpr_replica_globals.srch_cptr, cptr[i])) { if (0 > orte_pointer_array_add(&index, orte_gpr_replica_globals.srch_cptr, cptr[i])) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
orte_pointer_array_clear(orte_gpr_replica_globals.srch_cptr); orte_pointer_array_clear(orte_gpr_replica_globals.srch_cptr);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
}
(orte_gpr_replica_globals.num_srch_cptr)++;
} }
(*num_found)++;
} }
} }
return ORTE_SUCCESS; return ORTE_SUCCESS;
@ -87,6 +92,7 @@ int orte_gpr_replica_create_container(orte_gpr_replica_container_t **cptr,
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
(seg->num_containers)++;
(*cptr)->index = index; (*cptr)->index = index;
return ORTE_SUCCESS; return ORTE_SUCCESS;
@ -115,6 +121,7 @@ int orte_gpr_replica_release_container(orte_gpr_replica_segment_t *seg,
i = cptr->index; i = cptr->index;
OBJ_RELEASE(cptr); OBJ_RELEASE(cptr);
orte_pointer_array_set_item(seg->containers, i, NULL); orte_pointer_array_set_item(seg->containers, i, NULL);
(seg->num_containers)--;
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
@ -154,7 +161,8 @@ int orte_gpr_replica_add_keyval(orte_gpr_replica_itagval_t **ivalptr,
OBJ_RELEASE(iptr); OBJ_RELEASE(iptr);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
(cptr->num_itagvals)++;
if (0 > (rc = orte_value_array_append_item(&(cptr->itaglist), (void*)(&(iptr->itag))))) { if (0 > (rc = orte_value_array_append_item(&(cptr->itaglist), (void*)(&(iptr->itag))))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
orte_pointer_array_set_item(cptr->itagvals, iptr->index, NULL); orte_pointer_array_set_item(cptr->itagvals, iptr->index, NULL);
@ -192,6 +200,7 @@ int orte_gpr_replica_delete_itagval(orte_gpr_replica_segment_t *seg,
/* remove the entry from the container's itagval array */ /* remove the entry from the container's itagval array */
orte_pointer_array_set_item(cptr->itagvals, i, NULL); orte_pointer_array_set_item(cptr->itagvals, i, NULL);
(cptr->num_itagvals)--;
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
@ -226,7 +235,7 @@ int orte_gpr_replica_update_keyval(orte_gpr_replica_segment_t *seg,
OBJ_RELEASE(iptr); OBJ_RELEASE(iptr);
/* remove the entry from the container's itagval array */ /* remove the entry from the container's itagval array */
orte_pointer_array_set_item(cptr->itagvals, i, NULL); orte_pointer_array_set_item(cptr->itagvals, i, NULL);
(cptr->num_itagvals)--;
} }
} }
@ -255,16 +264,16 @@ int orte_gpr_replica_update_keyval(orte_gpr_replica_segment_t *seg,
} }
int orte_gpr_replica_search_container(size_t *cnt, orte_gpr_replica_addr_mode_t addr_mode, int orte_gpr_replica_search_container(orte_gpr_replica_addr_mode_t addr_mode,
orte_gpr_replica_itag_t *itags, size_t num_itags, orte_gpr_replica_itag_t *itags, size_t num_itags,
orte_gpr_replica_container_t *cptr) orte_gpr_replica_container_t *cptr)
{ {
orte_gpr_replica_itagval_t **ptr; orte_gpr_replica_itagval_t **ptr;
size_t i, index; size_t i, j, index;
/* ensure the search array is clear */ /* ensure the search array is clear */
orte_pointer_array_clear(orte_gpr_replica_globals.srch_ival); orte_pointer_array_clear(orte_gpr_replica_globals.srch_ival);
*cnt = 0; orte_gpr_replica_globals.num_srch_ival = 0;
/* check list of itags in container to see if there is a match according /* check list of itags in container to see if there is a match according
* to addr_mode spec * to addr_mode spec
@ -274,17 +283,21 @@ int orte_gpr_replica_search_container(size_t *cnt, orte_gpr_replica_addr_mode_t
ORTE_VALUE_ARRAY_GET_BASE(&(cptr->itaglist), orte_gpr_replica_itag_t))) { ORTE_VALUE_ARRAY_GET_BASE(&(cptr->itaglist), orte_gpr_replica_itag_t))) {
/* there is! so now collect those values into the search array */ /* there is! so now collect those values into the search array */
ptr = (orte_gpr_replica_itagval_t**)((cptr->itagvals)->addr); ptr = (orte_gpr_replica_itagval_t**)((cptr->itagvals)->addr);
for (i=0; i < (cptr->itagvals)->size; i++) { for (i=0, j=0; j < cptr->num_itagvals &&
if (NULL != ptr[i] && orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_OR, i < (cptr->itagvals)->size; i++) {
if (NULL != ptr[i]) {
j++;
if (orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_OR,
num_itags, itags, num_itags, itags,
1, &(ptr[i]->itag))) { 1, &(ptr[i]->itag))) {
if (0 > orte_pointer_array_add(&index, orte_gpr_replica_globals.srch_ival, ptr[i])) { if (0 > orte_pointer_array_add(&index, orte_gpr_replica_globals.srch_ival, ptr[i])) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
orte_pointer_array_clear(orte_gpr_replica_globals.srch_ival); orte_pointer_array_clear(orte_gpr_replica_globals.srch_ival);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
}
(orte_gpr_replica_globals.num_srch_ival)++;
} }
(*cnt)++;
} }
} }
} }
@ -597,6 +610,8 @@ int orte_gpr_replica_release_segment(orte_gpr_replica_segment_t **seg)
if (0 > (rc = orte_pointer_array_set_item(orte_gpr_replica.segments, i, NULL))) { if (0 > (rc = orte_pointer_array_set_item(orte_gpr_replica.segments, i, NULL))) {
return rc; return rc;
} }
(orte_gpr_replica.num_segs)--;
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }

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

@ -33,296 +33,65 @@
#include "mca/gpr/replica/transition_layer/gpr_replica_tl.h" #include "mca/gpr/replica/transition_layer/gpr_replica_tl.h"
#include "gpr_replica_fn.h" #include "gpr_replica_fn.h"
int orte_gpr_replica_subscribe_fn(orte_gpr_notify_action_t action, size_t num_subs, int orte_gpr_replica_subscribe_fn(orte_process_name_t *requestor,
size_t num_subs,
orte_gpr_subscription_t **subscriptions, orte_gpr_subscription_t **subscriptions,
size_t num_trigs, size_t num_trigs,
orte_gpr_value_t **trigs, orte_gpr_trigger_t **trigs)
orte_gpr_notify_id_t idtag)
{ {
orte_gpr_replica_triggers_t *trig=NULL; orte_gpr_replica_subscription_t *sub=NULL, **subs;
orte_gpr_replica_subscribed_data_t *data=NULL, **data2=NULL; orte_gpr_replica_trigger_t *trig=NULL;
orte_gpr_replica_counter_t *cntr; size_t i, j, k, index;
orte_gpr_replica_segment_t *seg=NULL;
orte_gpr_replica_container_t **cptr=NULL, *cptr2=NULL;
orte_gpr_replica_itag_t itag, *tokentags=NULL, *keytags=NULL;
orte_gpr_replica_itagval_t *iptr=NULL;
orte_gpr_replica_addr_mode_t tok_mode, key_mode;
size_t i, j, k, index, num_tokens, num_keys, num_found;
int rc=ORTE_SUCCESS; int rc=ORTE_SUCCESS;
bool found;
if (orte_gpr_replica_globals.debug) { if (orte_gpr_replica_globals.debug) {
ompi_output(0, "[%lu,%lu,%lu] gpr replica: subscribe entered - registering idtag %d", ompi_output(0, "[%lu,%lu,%lu] gpr replica: subscribe entered",
ORTE_NAME_ARGS(orte_process_info.my_name), idtag); ORTE_NAME_ARGS(orte_process_info.my_name));
ompi_output(0, "Received %d subscriptions", num_subs);
for (i=0; i < num_subs; i++) {
ompi_output(0, "Subscription %d on segment %s with %d tokens, %d keys",
i, subscriptions[i]->segment, subscriptions[i]->num_tokens,
subscriptions[i]->num_keys);
for (j=0; j < subscriptions[i]->num_tokens; j++) {
ompi_output(0, "\tToken num: %d\tToken: %s", j, subscriptions[i]->tokens[j]);
}
for (j=0; j < subscriptions[i]->num_keys; j++) {
ompi_output(0, "\tKey num: %d\tKey: %s", j, subscriptions[i]->keys[j]);
}
}
for (i=0; i < num_trigs; i++) {
ompi_output(0, "Trigger %d on segment %s with %d tokens, %d keyvals",
i, trigs[i]->segment, trigs[i]->num_tokens, trigs[i]->cnt);
for (j=0; j < trigs[i]->num_tokens; j++) {
ompi_output(0, "\tToken num: %d\tToken: %s", j, trigs[i]->tokens[j]);
}
for (j=0; j < trigs[i]->cnt; j++) {
ompi_output(0, "\tKey num: %d\tKey: %s", j, (trigs[i]->keyvals[j])->key);
}
}
} }
trig = (orte_gpr_replica_triggers_t*)((orte_gpr_replica.triggers)->addr[idtag]); /* ensure one of the search arrays is clear - in this case, we
if (NULL == trig) { * use the sub_ptrs array to temporarily store the subscription pointers so we
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); * can properly link them to the triggers
return ORTE_ERR_BAD_PARAM; */
} orte_pointer_array_clear(orte_gpr_replica_globals.sub_ptrs);
trig->action = action; subs = (orte_gpr_replica_subscription_t**)(orte_gpr_replica_globals.sub_ptrs)->addr;
for (i=0; i < num_subs; i++) { for (i=0; i < num_subs; i++) {
/* find the subscribed_data entry in the trigger pointer array - placed if (ORTE_SUCCESS != (rc =
* there initially by the enter_notify_request function so we could store orte_gpr_replica_register_subscription(&sub, requestor, subscriptions[i]))) {
* the callback function and user_tag pointers
*/
data2 = (orte_gpr_replica_subscribed_data_t**)((trig->subscribed_data)->addr);
for (j=0, data=NULL; j < (trig->subscribed_data)->size && NULL == data; j++) {
if (NULL != data2[j] && i == data2[j]->index) {
data = data2[j];
}
}
if (NULL == data) { /* if not found, then something very wrong */
ORTE_ERROR_LOG(ORTE_ERR_GPR_DATA_CORRUPT);
return ORTE_ERR_GPR_DATA_CORRUPT;
}
/* find and store the segment */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_seg(&(data->seg), true,
subscriptions[i]->segment))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
tok_mode = 0x004f & subscriptions[i]->addr_mode; /* add the new subscription so we can link
if (0x00 == tok_mode) { /* default token address mode to AND */ * it to the triggers later
tok_mode = ORTE_GPR_REPLICA_AND; */
} if (0 > orte_pointer_array_add(&index, orte_gpr_replica_globals.sub_ptrs, sub)) {
key_mode = ((0x4f00 & subscriptions[i]->addr_mode) >> 8) & 0x004f; ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
if (0x00 == key_mode) { /* default key address mode to OR */ return ORTE_ERR_OUT_OF_RESOURCE;
key_mode = ORTE_GPR_REPLICA_OR;
}
data->addr_mode = ((orte_gpr_addr_mode_t)(key_mode) << 8) | (orte_gpr_addr_mode_t)tok_mode;
if (NULL != subscriptions[i]->tokens && 0 < subscriptions[i]->num_tokens) {
num_tokens = subscriptions[i]->num_tokens; /* indicates non-NULL terminated list */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_itag_list(&tokentags, data->seg,
subscriptions[i]->tokens, &num_tokens))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_value_array_set_size(&(data->tokentags), (size_t)num_tokens))) {
ORTE_ERROR_LOG(rc);
return rc;
}
for (j=0; j < num_tokens; j++) {
ORTE_VALUE_ARRAY_SET_ITEM(&(data->tokentags), orte_gpr_replica_itag_t,
j, tokentags[j]);
}
free(tokentags);
tokentags = NULL;
}
if (NULL != subscriptions[i]->keys && 0 < subscriptions[i]->num_keys) {
num_keys = subscriptions[i]->num_keys; /* indicates non-NULL terminated list */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_itag_list(&keytags, data->seg,
subscriptions[i]->keys, &num_keys))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_value_array_set_size(&(data->keytags), (size_t)num_keys))) {
ORTE_ERROR_LOG(rc);
return rc;
}
for (j=0; j < num_keys; j++) {
ORTE_VALUE_ARRAY_SET_ITEM(&(data->keytags), orte_gpr_replica_itag_t,
j, keytags[j]);
}
free(keytags);
keytags = NULL;
} }
} }
/* if this has a trigger in it, need to setup the counters */ /* now register any triggers */
if (ORTE_GPR_TRIG_ANY & action) { for (i=0; i < num_trigs; i++) {
trig->num_counters = 0; if (ORTE_SUCCESS != (rc =
for (j=0; j < num_trigs; j++) { orte_gpr_replica_register_trigger(&trig, requestor, trigs[i]))) {
/* get this counter's addressing modes */ ORTE_ERROR_LOG(rc);
tok_mode = 0x004f & trigs[j]->addr_mode; return rc;
if (0x00 == tok_mode) { /* default token address mode to AND */ }
tok_mode = ORTE_GPR_REPLICA_AND; /* link the subscriptions to the new trigger
} */
key_mode = ((0x4f00 & trigs[j]->addr_mode) >> 8) & 0x004f; for (j=0, k=0; k < num_subs &&
if (0x00 == key_mode) { /* default key address mode to OR */ j < (orte_gpr_replica_globals.sub_ptrs)->size; j++) {
key_mode = ORTE_GPR_REPLICA_OR; if (NULL != subs[j]) {
} k++;
if (0 > orte_pointer_array_add(&index, trig->subscriptions, subs[j])) {
/* locate this counter's segment - this is where the counter will be */ ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_seg(&seg, true, trigs[j]->segment))) { return ORTE_ERR_OUT_OF_RESOURCE;
ORTE_ERROR_LOG(rc);
OMPI_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
/* convert the counter's tokens to an itaglist */
if (NULL != trigs[j]->tokens && 0 < trigs[j]->num_tokens) {
num_tokens = trigs[j]->num_tokens; /* indicates non-NULL terminated list */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_itag_list(&tokentags, seg,
trigs[j]->tokens, &num_tokens))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
} }
} }
}
/* find the specified container(s) */ trig->num_subscriptions += num_subs;
if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_containers(&num_found, seg, tok_mode,
tokentags, num_tokens))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
if (0 == num_found) { /* 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 counters values in the new container, adding a pointer to each
* one in the trigger's counter array
*/
for (i=0; i < trigs[j]->cnt; i++) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_add_keyval(&iptr, seg, cptr2, trigs[j]->keyvals[i]))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
cntr = OBJ_NEW(orte_gpr_replica_counter_t);
if (NULL == cntr) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
cntr->seg = seg;
cntr->cptr = cptr2;
cntr->iptr = iptr;
cntr->trigger_level.type = (trigs[j]->keyvals[i])->type;
if (ORTE_SUCCESS != (rc = orte_gpr_base_xfer_payload(&(cntr->trigger_level.value),
&((trigs[j]->keyvals[i])->value), (trigs[j]->keyvals[i])->type))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
if (0 > orte_pointer_array_add(&index, trig->counters, cntr)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
}
trig->num_counters += trigs[j]->cnt;
} else { /* For each counter, go through the list of containers and
see if it already exists in container. Only allow each
counter to be identified once - error if either a counter is never
found or already existing in more than one place. */
cptr = (orte_gpr_replica_container_t**)(orte_gpr_replica_globals.srch_cptr)->addr;
for (i=0; i < trigs[j]->cnt; i++) {
found = false;
for (k=0; k < (orte_gpr_replica_globals.srch_cptr)->size; k++) {
if (NULL != cptr[k]) {
if (ORTE_SUCCESS == orte_gpr_replica_dict_lookup(&itag, seg, trigs[j]->keyvals[i]->key) &&
ORTE_SUCCESS == orte_gpr_replica_search_container(&num_found,
ORTE_GPR_REPLICA_OR,
&itag, 1, cptr[k]) &&
0 < num_found) {
/* this key already exists - make sure it's unique
*/
if (1 < num_found || found) { /* not unique - error out */
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
rc = ORTE_ERR_BAD_PARAM;
goto CLEANUP;
}
/* okay, add to trigger's counter array */
found = true;
iptr = (orte_gpr_replica_itagval_t*)((orte_gpr_replica_globals.srch_ival)->addr[0]);
cntr = OBJ_NEW(orte_gpr_replica_counter_t);
if (NULL == cntr) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
cntr->seg = seg;
cntr->cptr = cptr[k];
cntr->iptr = iptr;
cntr->trigger_level.type = (trigs[j]->keyvals[i])->type;
if (ORTE_SUCCESS != (rc = orte_gpr_base_xfer_payload(&(cntr->trigger_level.value),
&((trigs[j]->keyvals[i])->value), (trigs[j]->keyvals[i])->type))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
if (0 > orte_pointer_array_add(&index, trig->counters, cntr)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
(trig->num_counters)++;
} /* end if found */
} /* end if cptr NULL */
} /* end for j */
if (!found) { /* specified counter never found - error */
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
rc = ORTE_ERR_BAD_PARAM;
goto CLEANUP;
} /* end if found */
} /* end for i */
} /* end if/else container found */
/* check the triggers on this segment before leaving to see if they are already fired */
if (ORTE_SUCCESS !=
(rc = orte_gpr_replica_check_subscriptions(seg))) {
ORTE_ERROR_LOG(rc);
return rc;
}
} /* end for j */
} /* end if trigger */
CLEANUP:
if (NULL != tokentags) {
free(tokentags);
} }
if (ORTE_SUCCESS != rc) OBJ_RELEASE(trig);
return rc; return rc;
} }
int orte_gpr_replica_unsubscribe_fn(orte_gpr_notify_id_t sub_number)
{
orte_gpr_replica_triggers_t *trig;
if (orte_gpr_replica_globals.debug) {
ompi_output(0, "[%lu,%lu,%lu] gpr replica: unsubscribe entered for sub number %d",
ORTE_NAME_ARGS(orte_process_info.my_name), sub_number);
}
/* release trigger on replica and remove it */
trig = (orte_gpr_replica_triggers_t*)((orte_gpr_replica.triggers)->addr[sub_number]);
if (NULL == trig) {
return ORTE_ERR_BAD_PARAM;
}
OBJ_RELEASE(trig);
orte_pointer_array_set_item(orte_gpr_replica.triggers, sub_number, NULL);
return ORTE_SUCCESS;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -77,22 +77,36 @@ typedef uint8_t orte_gpr_replica_addr_mode_t;
typedef int8_t orte_gpr_replica_action_t; typedef int8_t orte_gpr_replica_action_t;
/*
* Local subscription tracker for use by processes
* that are operating on the same node as the replica
*/
typedef struct {
ompi_object_t super; /**< Allows this to be an object */
orte_gpr_subscription_id_t id; /**< id of this subscription */
orte_gpr_notify_cb_fn_t callback; /**< Function to be called for notificaiton */
void *user_tag; /**< User-provided tag for callback function */
} orte_gpr_replica_local_subscriber_t;
OBJ_CLASS_DECLARATION(orte_gpr_replica_local_subscriber_t);
typedef struct { typedef struct {
int debug; int debug;
int isolate; int isolate;
size_t block_size; size_t block_size;
size_t max_size; size_t max_size;
ompi_mutex_t mutex; ompi_mutex_t mutex;
bool compound_cmd_mode; size_t num_local_subs;
bool exec_compound_cmd_mode; orte_pointer_array_t *local_subscriptions;
orte_buffer_t *compound_cmd; size_t trig_cntr;
ompi_mutex_t wait_for_compound_mutex; size_t num_srch_cptr;
ompi_condition_t compound_cmd_condition;
int compound_cmd_waiting;
orte_pointer_array_t *srch_cptr; orte_pointer_array_t *srch_cptr;
orte_pointer_array_t *sub_ptrs;
size_t num_srch_ival;
orte_pointer_array_t *srch_ival; orte_pointer_array_t *srch_ival;
orte_pointer_array_t *acted_upon;
size_t num_acted_upon; size_t num_acted_upon;
orte_pointer_array_t *acted_upon;
orte_bitmap_t srch_itag; orte_bitmap_t srch_itag;
} orte_gpr_replica_globals_t; } orte_gpr_replica_globals_t;
@ -125,6 +139,8 @@ struct orte_gpr_replica_t {
size_t num_segs; size_t num_segs;
orte_pointer_array_t *triggers; /**< Managed array of pointers to triggers */ orte_pointer_array_t *triggers; /**< Managed array of pointers to triggers */
size_t num_trigs; size_t num_trigs;
orte_pointer_array_t *subscriptions; /**< Managed array of pointers to subscriptions */
size_t num_subs;
bool processing_callbacks; bool processing_callbacks;
ompi_list_t callbacks; /**< List of callbacks to be processed */ ompi_list_t callbacks; /**< List of callbacks to be processed */
}; };
@ -144,7 +160,9 @@ struct orte_gpr_replica_segment_t {
ompi_object_t super; /**< Make this an object */ ompi_object_t super; /**< Make this an object */
char *name; /**< Name of the segment */ char *name; /**< Name of the segment */
orte_gpr_replica_itag_t itag; /**< itag of this segment */ orte_gpr_replica_itag_t itag; /**< itag of this segment */
size_t num_dict_entries;
orte_pointer_array_t *dict; /**< Managed array of dict structs */ orte_pointer_array_t *dict; /**< Managed array of dict structs */
size_t num_containers;
orte_pointer_array_t *containers; /**< Managed array of pointers to containers on this segment */ orte_pointer_array_t *containers; /**< Managed array of pointers to containers on this segment */
}; };
typedef struct orte_gpr_replica_segment_t orte_gpr_replica_segment_t; typedef struct orte_gpr_replica_segment_t orte_gpr_replica_segment_t;
@ -177,6 +195,7 @@ struct orte_gpr_replica_container_t {
orte_gpr_replica_itag_t *itags; /**< Array of itags that define this container */ orte_gpr_replica_itag_t *itags; /**< Array of itags that define this container */
size_t num_itags; /**< Number of itags in array */ size_t num_itags; /**< Number of itags in array */
orte_pointer_array_t *itagvals; /**< Array of itagval pointers */ orte_pointer_array_t *itagvals; /**< Array of itagval pointers */
size_t num_itagvals; /**< Number of itagvals in container */
orte_value_array_t itaglist; /**< Array of itags from all itagvals - used for rapid search */ orte_value_array_t itaglist; /**< Array of itags from all itagvals - used for rapid search */
}; };
typedef struct orte_gpr_replica_container_t orte_gpr_replica_container_t; typedef struct orte_gpr_replica_container_t orte_gpr_replica_container_t;
@ -196,6 +215,23 @@ typedef struct {
OBJ_CLASS_DECLARATION(orte_gpr_replica_itagval_t); OBJ_CLASS_DECLARATION(orte_gpr_replica_itagval_t);
/* The equivalent of the value structure, only using internal
* itags for the tokens/keys and pointers to internal structures
*/
typedef struct {
ompi_object_t super; /**< Makes this an object */
size_t index;
/* the segment upon which this data is located */
orte_gpr_replica_segment_t *seg;
/* describe the data */
orte_gpr_addr_mode_t addr_mode; /**< Tokens/keys addressing mode */
orte_value_array_t tokentags; /**< Array of tokens defining which containers are affected */
orte_value_array_t keytags; /**< Array of keys defining which key-value pairs are affected */
} orte_gpr_replica_ivalue_t;
OBJ_CLASS_DECLARATION(orte_gpr_replica_ivalue_t);
typedef struct { typedef struct {
ompi_object_t super; ompi_object_t super;
orte_gpr_replica_segment_t *seg; orte_gpr_replica_segment_t *seg;
@ -207,58 +243,101 @@ typedef struct {
OBJ_CLASS_DECLARATION(orte_gpr_replica_counter_t); OBJ_CLASS_DECLARATION(orte_gpr_replica_counter_t);
typedef struct { typedef struct {
ompi_object_t super; /**< Makes this an object */ ompi_object_t super;
size_t index; /**< Index of this entry in original subscription */ /* index of this entry in requestor array */
/* the segment upon which this data is located */
orte_gpr_replica_segment_t *seg;
/* describe the data to be returned with the message -
* for triggers that are counting themselves (i.e., not monitoring a separate
* counter), this also describes the data to be included in the count
*/
orte_gpr_addr_mode_t addr_mode; /**< Tokens/keys addressing mode */
orte_value_array_t tokentags; /**< Array of tokens defining which containers are affected */
orte_value_array_t keytags; /**< Array of keys defining which key-value pairs are affected */
/* 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_subscribed_data_t;
OBJ_CLASS_DECLARATION(orte_gpr_replica_subscribed_data_t);
struct orte_gpr_replica_triggers_t {
ompi_object_t super; /**< Make this an object */
/* index of this trigger in the triggers array */
size_t index; size_t index;
/* process name of the recipient - set to NULL if local */
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 {
ompi_object_t super; /**< Makes this an object */
/* index of this entry in subscription array - corresponds to local idtag */
size_t index;
/* name of this subscription, if provided */
char *name;
/* boolean indicating if this subscription is active or not */
bool active;
/* boolean indicating that this subscription
* should be removed after processing
* is completed
*/
bool cleanup;
/* action flags describing when the subscription should
* generate a notification message. This can be NULL if
* the subscription only operates in conjunction
* with a trigger
*/
orte_gpr_notify_action_t action;
/* Array of ivalues that describe the data to be
* returned when this subscription is "fired"
*/
size_t num_values;
orte_pointer_array_t *values;
/*
* Array of requestors that are "attached" to this subscription
*/
size_t num_requestors;
orte_pointer_array_t *requestors;
} orte_gpr_replica_subscription_t;
OBJ_CLASS_DECLARATION(orte_gpr_replica_subscription_t);
typedef struct {
ompi_object_t super;
/* index of this entry in array */
size_t index;
/* process name of the requestor - set to NULL if local */
orte_process_name_t *requestor;
/* requestor's id for this trigger */
orte_gpr_trigger_id_t idtag;
} orte_gpr_replica_trigger_requestor_t;
OBJ_CLASS_DECLARATION(orte_gpr_replica_trigger_requestor_t);
struct orte_gpr_replica_trigger_t {
ompi_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 */
size_t index;
/* array of requestors that have "attached" themselves to this trigger */
size_t num_attached;
orte_pointer_array_t *attached;
/* the action that causes the trigger to be fired */
orte_gpr_notify_action_t action;
/* flag that indicates this trigger is a one-shot, has fired and /* flag that indicates this trigger is a one-shot, has fired and
* now should be cleaned up * now should be cleaned up
*/ */
bool one_shot_fired; bool one_shot_fired;
/* the action that causes a notification message to be sent out */ /* pointers to the counters being monitored. This could
orte_gpr_notify_action_t action;
/* to whom the notification messages go - set to NULL if local */
orte_process_name_t *requestor; /**< Name of requesting process */
/* remote idtag associated with this subscription -
* set to ORTE_GPR_NOTIFY_ID_MAX if local
*/
orte_gpr_notify_id_t remote_idtag; /**< Remote ID tag of subscription */
/* a pointer to the data belonging to this subscription. Each subscribed data
* object describes a set of data to be returned whenever this subscription
* fires. for subscriptions that do not involve trigger events, these objects
* describe the data being monitored
*/
size_t num_subscribed_data;
orte_pointer_array_t *subscribed_data;
/* for triggers, store a pointer to the counters being monitored. This could
* be counters we are using ourselves, or could be counters being run by someone * be counters we are using ourselves, or could be counters being run by someone
* else. Store the trigger level for each counter that we are monitoring until they reach * else. For those triggers that fire at a specified level (as opposed to
* a specified level (as opposed to comparing values in two or more counters). * comparing values in two or more counters), store the trigger level for
* each counter that we are monitoring until they reach a specified level.
*/ */
size_t num_counters; size_t num_counters;
orte_pointer_array_t *counters; orte_pointer_array_t *counters;
/* a pointer to the subscriptions associated with this trigger. These
* describe the data that will be returned when the trigger fires, and to
* whom and where it goes.
*/
size_t num_subscriptions;
orte_pointer_array_t *subscriptions;
}; };
typedef struct orte_gpr_replica_triggers_t orte_gpr_replica_triggers_t; typedef struct orte_gpr_replica_trigger_t orte_gpr_replica_trigger_t;
OBJ_CLASS_DECLARATION(orte_gpr_replica_trigger_t);
OBJ_CLASS_DECLARATION(orte_gpr_replica_triggers_t);
/* /*
* Action taken object - used to track what action was taken against what * Action taken object - used to track what action was taken against what
@ -277,25 +356,13 @@ typedef struct {
OBJ_CLASS_DECLARATION(orte_gpr_replica_action_taken_t); OBJ_CLASS_DECLARATION(orte_gpr_replica_action_taken_t);
/*
* Notify message list objects - used to track individual messages going to
* the same recipient
*/
typedef struct {
ompi_list_item_t item;
orte_gpr_notify_message_t *message;
} orte_gpr_replica_notify_msg_list_t;
OBJ_CLASS_DECLARATION(orte_gpr_replica_notify_msg_list_t);
/* /*
* Callback list objects * Callback list objects
*/ */
struct orte_gpr_replica_callbacks_t { struct orte_gpr_replica_callbacks_t {
ompi_list_item_t item; ompi_list_item_t item;
ompi_list_t messages;
orte_process_name_t *requestor; orte_process_name_t *requestor;
orte_gpr_notify_message_t *message;
}; };
typedef struct orte_gpr_replica_callbacks_t orte_gpr_replica_callbacks_t; typedef struct orte_gpr_replica_callbacks_t orte_gpr_replica_callbacks_t;

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

@ -0,0 +1,536 @@
/* -*- 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,
* 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
*/
#ifndef ORTE_GPR_REPLICA_CLASS_INSTANCES_H_
#define ORTE_GPR_REPLICA_CLASS_INSTANCES_H_
#include "orte_config.h"
#include "class/orte_bitmap.h"
#include "class/ompi_object.h"
#include "gpr_replica.h"
/*
* CONSTRUCTORS, DESTRUCTORS, AND CLASS INSTANTIATIONS
* FOR GPR REPLICA CLASSES
*/
/* LOCAL_SUBSCRIBER */
/* no constructor or destructor needed, so just
* define instance */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_local_subscriber_t, /* type name */
ompi_object_t, /* parent "class" name */
NULL, /* constructor */
NULL); /* destructor */
/* SEGMENT */
/* constructor - used to initialize state of segment instance */
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_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size);
seg->num_containers = 0;
orte_pointer_array_init(&(seg->containers), orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size);
}
/* destructor - used to free any resources held by instance */
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);
}
if (NULL != seg->dict) {
dptr = (orte_gpr_replica_dict_t**)((seg->dict)->addr);
for (i=0, k=0; k < seg->num_dict_entries &&
i < (seg->dict)->size; i++) {
if (NULL != dptr[i]) {
k++;
if (NULL != dptr[i]->entry) {
free(dptr[i]->entry);
}
free(dptr[i]);
}
}
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 &&
i < (seg->containers)->size; i++) {
if (NULL != cptr[i]) {
k++;
OBJ_RELEASE(cptr[i]);
}
}
OBJ_RELEASE(seg->containers);
}
}
/* define instance of orte_gpr_replica_segment_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_segment_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_segment_construct, /* constructor */
orte_gpr_replica_segment_destructor); /* destructor */
/* CONTAINER */
/* constructor - used to initialize state of registry container instance */
static void orte_gpr_replica_container_construct(orte_gpr_replica_container_t* reg)
{
reg->index = 0;
reg->itags = NULL;
reg->num_itags = 0;
orte_pointer_array_init(&(reg->itagvals), orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.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));
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_container_destructor(orte_gpr_replica_container_t* reg)
{
orte_gpr_replica_itagval_t **ptr;
size_t i, k;
if (NULL != reg->itags) {
free(reg->itags);
}
if (NULL != reg->itagvals) {
ptr = (orte_gpr_replica_itagval_t**)((reg->itagvals)->addr);
for (i=0, k=0; k < reg->num_itagvals &&
i < (reg->itagvals)->size; i++) {
if (NULL != ptr[i]) {
k++;
OBJ_RELEASE(ptr[i]);
}
}
OBJ_RELEASE(reg->itagvals);
}
OBJ_DESTRUCT(&(reg->itaglist));
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_container_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_container_construct, /* constructor */
orte_gpr_replica_container_destructor); /* destructor */
/* ITAG-VALUE PAIR */
/* constructor - used to initialize state of itagval instance */
static void orte_gpr_replica_itagval_construct(orte_gpr_replica_itagval_t* ptr)
{
ptr->index = 0;
ptr->itag = ORTE_GPR_REPLICA_ITAG_MAX;
ptr->type = ORTE_NULL;
(ptr->value).i32 = 0;
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_itagval_destructor(orte_gpr_replica_itagval_t* ptr)
{
if (ORTE_BYTE_OBJECT == ptr->type) {
free(((ptr->value).byteobject).bytes);
} else if (ORTE_STRING == ptr->type) {
if (NULL != ptr->value.strptr)
free(ptr->value.strptr);
} else if (ORTE_APP_CONTEXT == ptr->type) {
if (NULL != ptr->value.app_context)
OBJ_RELEASE(ptr->value.app_context);
}
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_itagval_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_itagval_construct, /* constructor */
orte_gpr_replica_itagval_destructor); /* destructor */
/* IVALUE */
/* constructor - used to initialize state of ivalue instance */
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));
OBJ_CONSTRUCT(&(ptr->keytags), orte_value_array_t);
orte_value_array_init(&(ptr->keytags), sizeof(orte_gpr_replica_itag_t));
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_ivalue_destructor(orte_gpr_replica_ivalue_t* ptr)
{
OBJ_DESTRUCT(&(ptr->tokentags));
OBJ_DESTRUCT(&(ptr->keytags));
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_ivalue_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_ivalue_construct, /* constructor */
orte_gpr_replica_ivalue_destructor); /* destructor */
/* COUNTERS */
/* constructor - used to initialize state of counter instance */
static void orte_gpr_replica_counter_construct(orte_gpr_replica_counter_t* cntr)
{
cntr->seg = NULL;
cntr->cptr = NULL;
cntr->iptr = NULL;
OBJ_CONSTRUCT(&(cntr->trigger_level), orte_gpr_replica_itagval_t);
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_counter_destructor(orte_gpr_replica_counter_t* cntr)
{
OBJ_DESTRUCT(&(cntr->trigger_level));
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_counter_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_counter_construct, /* constructor */
orte_gpr_replica_counter_destructor); /* destructor */
/* REQUESTOR */
/* constructor - used to initialize state of requestor instance */
static void orte_gpr_replica_requestor_construct(orte_gpr_replica_requestor_t* ptr)
{
ptr->index = 0;
ptr->requestor = NULL;
ptr->idtag = 0;
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_requestor_destructor(orte_gpr_replica_requestor_t* ptr)
{
if (NULL != ptr->requestor) free(ptr->requestor);
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_requestor_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_requestor_construct, /* constructor */
orte_gpr_replica_requestor_destructor); /* destructor */
/* SUBSCRIPTION */
/* constructor - used to initialize state of subscription instance */
static void orte_gpr_replica_subscription_construct(orte_gpr_replica_subscription_t* sub)
{
sub->index = 0;
sub->name = NULL;
sub->active = false;
sub->cleanup = false;
sub->action = ORTE_GPR_REPLICA_NO_ACTION;
sub->num_values = 0;
orte_pointer_array_init(&(sub->values), orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size);
sub->num_requestors = 0;
orte_pointer_array_init(&(sub->requestors), orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size);
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_subscription_destructor(orte_gpr_replica_subscription_t* sub)
{
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) {
ptr = (orte_gpr_replica_requestor_t**)((sub->requestors)->addr);
for (i=0, k=0; k < sub->num_requestors &&
i < (sub->requestors)->size; i++) {
if (NULL != ptr[i]) {
k++;
OBJ_RELEASE(ptr[i]);
}
}
OBJ_RELEASE(sub->requestors);
}
if (NULL != sub->values) {
ivals = (orte_gpr_replica_ivalue_t**)((sub->values)->addr);
for (i=0, k=0; k < sub->num_values &&
i < (sub->values)->size; i++) {
if (NULL != ivals[i]) {
k++;
OBJ_RELEASE(ivals[i]);
}
}
OBJ_RELEASE(sub->values);
}
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_subscription_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_subscription_construct, /* constructor */
orte_gpr_replica_subscription_destructor); /* destructor */
/* TRIGGER REQUESTOR */
/* constructor - used to initialize state of instance */
static void orte_gpr_replica_trigger_requestor_construct(orte_gpr_replica_trigger_requestor_t* ptr)
{
ptr->index = 0;
ptr->requestor = NULL;
ptr->idtag = 0;
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_trigger_requestor_destructor(orte_gpr_replica_trigger_requestor_t* ptr)
{
if (NULL != ptr->requestor) free(ptr->requestor);
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_trigger_requestor_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_trigger_requestor_construct, /* constructor */
orte_gpr_replica_trigger_requestor_destructor); /* destructor */
/* TRIGGER */
/* constructor - used to initialize state of trigger instance */
static void orte_gpr_replica_trigger_construct(orte_gpr_replica_trigger_t* trig)
{
trig->name = NULL;
trig->index = 0;
trig->num_attached = 0;
orte_pointer_array_init(&(trig->attached), orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size);
trig->action = ORTE_GPR_REPLICA_NO_ACTION;
trig->one_shot_fired = false;
trig->num_counters = 0;
orte_pointer_array_init(&(trig->counters), orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size);
trig->num_subscriptions = 0;
orte_pointer_array_init(&(trig->subscriptions), orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size);
}
/* destructor - used to free any resources held by instance */
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);
}
/* must go through the array of atached and release
* the memory for each one prior to releasing the array
*/
if (NULL != trig->attached) {
att = (orte_gpr_replica_trigger_requestor_t**)((trig->attached)->addr);
cnt = 0;
for (i=0; cnt < trig->num_attached && i < (trig->attached)->size; i++) {
if (NULL != att[i]) {
cnt++;
OBJ_RELEASE(att[i]);
}
}
OBJ_RELEASE(trig->attached);
}
/* must go through the array of counters and release
* the memory for each one prior to releasing the array
*/
if (NULL != trig->counters) {
cntrs = (orte_gpr_replica_counter_t**)((trig->counters)->addr);
cnt = 0;
for (i=0; cnt < trig->num_counters && i < (trig->counters)->size; i++) {
if (NULL != cntrs[i]) {
cnt++;
OBJ_RELEASE(cntrs[i]);
}
}
OBJ_RELEASE(trig->counters);
}
/* the array of subscriptions is separately maintained, so we
* do NOT release the subscription memory here. We only release
* the array of pointers we were using to reference into the
* subscription array
*/
if (NULL != trig->subscriptions) {
OBJ_RELEASE(trig->subscriptions);
}
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_trigger_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_trigger_construct, /* constructor */
orte_gpr_replica_trigger_destructor); /* destructor */
/* ACTION_TAKEN */
/* constructor - used to initialize state of action_take instance */
static void orte_gpr_replica_action_taken_construct(orte_gpr_replica_action_taken_t* ptr)
{
ptr->action = ORTE_GPR_REPLICA_NO_ACTION;
ptr->seg = NULL;
ptr->cptr = NULL;
ptr->iptr = NULL;
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_action_taken_destructor(orte_gpr_replica_action_taken_t* ptr)
{
/* since we did a "RETAIN" on the objects pointed to by this object,
* we need to "RELEASE" them to indicate we are done with them
*/
if (NULL != ptr->seg) OBJ_RELEASE(ptr->seg);
if (NULL != ptr->cptr) OBJ_RELEASE(ptr->cptr);
if (NULL != ptr->iptr) OBJ_RELEASE(ptr->iptr);
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_action_taken_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_action_taken_construct, /* constructor */
orte_gpr_replica_action_taken_destructor); /* destructor */
/* CALLBACKS */
/* constructor - used to initialize state of callback list instance */
static void orte_gpr_replica_callbacks_construct(orte_gpr_replica_callbacks_t* cb)
{
cb->message = NULL;
cb->requestor = NULL;
}
/* destructor - used to free any resources held by instance */
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 ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_callbacks_t, /* type name */
ompi_list_item_t, /* parent "class" name */
orte_gpr_replica_callbacks_construct, /* constructor */
orte_gpr_replica_callbacks_destructor); /* destructor */
/* REPLICA LIST - NOT IMPLEMENTED YET! */
/* constructor - used to initialize state of replica list instance */
static void orte_gpr_replica_list_construct(orte_gpr_replica_list_t* replica)
{
replica->replica = NULL;
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_list_destructor(orte_gpr_replica_list_t* replica)
{
if (NULL != replica->replica) {
free(replica->replica);
replica->replica = NULL;
}
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_list_t, /* type name */
ompi_list_item_t, /* parent "class" name */
orte_gpr_replica_list_construct, /* constructor */
orte_gpr_replica_list_destructor); /* destructor */
/* WRITE INVALIDATE - NOT IMPLEMENTED YET! */
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_write_invalidate_t, /* type name */
ompi_list_item_t, /* parent "class" name */
NULL, /* constructor */
NULL); /* destructor */
#endif /* _GPR_REPLICA_CLASS_INSTANCES_H_ */

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

@ -86,6 +86,7 @@ static orte_gpr_base_module_t orte_gpr_replica_module = {
/* SUBSCRIBE OPERATIONS */ /* SUBSCRIBE OPERATIONS */
orte_gpr_replica_subscribe, orte_gpr_replica_subscribe,
orte_gpr_replica_unsubscribe, orte_gpr_replica_unsubscribe,
orte_gpr_replica_cancel_trigger,
/* COMPOUND COMMANDS */ /* COMPOUND COMMANDS */
orte_gpr_replica_begin_compound_cmd, orte_gpr_replica_begin_compound_cmd,
orte_gpr_replica_stop_compound_cmd, orte_gpr_replica_stop_compound_cmd,
@ -94,6 +95,7 @@ static orte_gpr_base_module_t orte_gpr_replica_module = {
orte_gpr_replica_dump_all, orte_gpr_replica_dump_all,
orte_gpr_replica_dump_segments, orte_gpr_replica_dump_segments,
orte_gpr_replica_dump_triggers, orte_gpr_replica_dump_triggers,
orte_gpr_replica_dump_subscriptions,
orte_gpr_replica_dump_callbacks, orte_gpr_replica_dump_callbacks,
orte_gpr_replica_dump_notify_msg, orte_gpr_replica_dump_notify_msg,
orte_gpr_replica_dump_notify_data, orte_gpr_replica_dump_notify_data,
@ -116,396 +118,8 @@ orte_gpr_replica_t orte_gpr_replica;
orte_gpr_replica_globals_t orte_gpr_replica_globals; orte_gpr_replica_globals_t orte_gpr_replica_globals;
/* /* instantiate the classes */
* CONSTRUCTORS AND DESTRUCTORS #include "mca/gpr/replica/gpr_replica_class_instances.h"
*/
/* SEGMENT */
/* constructor - used to initialize state of segment instance */
static void orte_gpr_replica_segment_construct(orte_gpr_replica_segment_t* seg)
{
seg->name = NULL;
seg->itag = ORTE_GPR_REPLICA_ITAG_MAX;
orte_pointer_array_init(&(seg->dict), orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size);
orte_pointer_array_init(&(seg->containers), orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size);
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_segment_destructor(orte_gpr_replica_segment_t* seg)
{
size_t i, j;
orte_gpr_replica_dict_t **dptr;
orte_gpr_replica_container_t **cptr;
if (NULL != seg->name) {
free(seg->name);
}
if (NULL != seg->dict) {
dptr = (orte_gpr_replica_dict_t**)((seg->dict)->addr);
for (i=0; i < (seg->dict)->size; i++) {
if (NULL != dptr[i]) {
if (NULL != dptr[i]->entry) {
free(dptr[i]->entry);
}
free(dptr[i]);
}
}
OBJ_RELEASE(seg->dict);
}
if (NULL != seg->containers) {
cptr = (orte_gpr_replica_container_t**)((seg->containers)->addr);
for (i=0; i < (seg->containers)->size; i++) {
if (NULL != cptr[i]) {
j = i;
OBJ_RELEASE(cptr[i]);
orte_pointer_array_set_item(seg->containers, j, NULL);
}
}
OBJ_RELEASE(seg->containers);
}
}
/* define instance of orte_gpr_replica_segment_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_segment_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_segment_construct, /* constructor */
orte_gpr_replica_segment_destructor); /* destructor */
/* CONTAINER */
/* constructor - used to initialize state of registry container instance */
static void orte_gpr_replica_container_construct(orte_gpr_replica_container_t* reg)
{
orte_pointer_array_init(&(reg->itagvals), orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size);
OBJ_CONSTRUCT(&(reg->itaglist), orte_value_array_t);
orte_value_array_init(&(reg->itaglist), sizeof(orte_gpr_replica_itag_t));
reg->itags = NULL;
reg->num_itags = 0;
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_container_destructor(orte_gpr_replica_container_t* reg)
{
orte_gpr_replica_itagval_t **ptr;
size_t i, j;
if (NULL != reg->itags) {
free(reg->itags);
}
if (NULL != reg->itagvals) {
ptr = (orte_gpr_replica_itagval_t**)((reg->itagvals)->addr);
for (i=0; i < (reg->itagvals)->size; i++) {
if (NULL != ptr[i]) {
j = i;
OBJ_RELEASE(ptr[i]);
orte_pointer_array_set_item(reg->itagvals, j, NULL);
}
}
OBJ_RELEASE(reg->itagvals);
}
OBJ_DESTRUCT(&(reg->itaglist));
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_container_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_container_construct, /* constructor */
orte_gpr_replica_container_destructor); /* destructor */
/* ITAG-VALUE PAIR */
/* constructor - used to initialize state of itagval instance */
static void orte_gpr_replica_itagval_construct(orte_gpr_replica_itagval_t* ptr)
{
ptr->index = 0;
ptr->itag = ORTE_GPR_REPLICA_ITAG_MAX;
ptr->type = ORTE_NULL;
(ptr->value).i32 = 0;
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_itagval_destructor(orte_gpr_replica_itagval_t* ptr)
{
if (ORTE_BYTE_OBJECT == ptr->type) {
free(((ptr->value).byteobject).bytes);
} else if (ORTE_STRING == ptr->type) {
if (NULL != ptr->value.strptr)
free(ptr->value.strptr);
} else if (ORTE_APP_CONTEXT == ptr->type) {
if (NULL != ptr->value.app_context)
OBJ_RELEASE(ptr->value.app_context);
}
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_itagval_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_itagval_construct, /* constructor */
orte_gpr_replica_itagval_destructor); /* destructor */
/* COUNTERS */
/* constructor - used to initialize state of counter instance */
static void orte_gpr_replica_counter_construct(orte_gpr_replica_counter_t* cntr)
{
cntr->seg = NULL;
cntr->cptr = NULL;
cntr->iptr = NULL;
OBJ_CONSTRUCT(&(cntr->trigger_level), orte_gpr_replica_itagval_t);
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_counter_destructor(orte_gpr_replica_counter_t* cntr)
{
OBJ_DESTRUCT(&(cntr->trigger_level));
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_counter_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_counter_construct, /* constructor */
orte_gpr_replica_counter_destructor); /* destructor */
/* SUBSCRIBED DATA */
/* constructor - used to initialize state of subscribed data instance */
static void orte_gpr_replica_subscribed_data_construct(orte_gpr_replica_subscribed_data_t* data)
{
data->seg = NULL;
data->addr_mode = 0;
OBJ_CONSTRUCT(&(data->tokentags), orte_value_array_t);
orte_value_array_init(&(data->tokentags), sizeof(orte_gpr_replica_itag_t));
OBJ_CONSTRUCT(&(data->keytags), orte_value_array_t);
orte_value_array_init(&(data->keytags), sizeof(orte_gpr_replica_itag_t));
data->callback = NULL;
data->user_tag = NULL;
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_subscribed_data_destructor(orte_gpr_replica_subscribed_data_t* data)
{
OBJ_DESTRUCT(&(data->tokentags));
OBJ_DESTRUCT(&(data->keytags));
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_subscribed_data_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_subscribed_data_construct, /* constructor */
orte_gpr_replica_subscribed_data_destructor); /* destructor */
/* TRIGGERS */
/* constructor - used to initialize state of trigger instance */
static void orte_gpr_replica_trigger_construct(orte_gpr_replica_triggers_t* trig)
{
trig->index = 0;
trig->action = 0;
trig->one_shot_fired = false;
trig->requestor = NULL;
trig->remote_idtag = ORTE_GPR_NOTIFY_ID_MAX;
trig->num_subscribed_data = 0;
orte_pointer_array_init(&(trig->subscribed_data), 10,
orte_gpr_replica_globals.max_size, 10);
trig->num_counters = 0;
orte_pointer_array_init(&(trig->counters), 1, orte_gpr_replica_globals.max_size, 1);
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_trigger_destructor(orte_gpr_replica_triggers_t* trig)
{
size_t i, j;
orte_gpr_replica_subscribed_data_t **data;
orte_gpr_replica_counter_t **cntrs;
if (NULL != trig->requestor) {
free(trig->requestor);
}
if (NULL != trig->subscribed_data) {
data = (orte_gpr_replica_subscribed_data_t**)((trig->subscribed_data)->addr);
for (i=0; i < (trig->subscribed_data)->size; i++) {
if (NULL != data[i]) {
j = i;
OBJ_RELEASE(data[i]);
orte_pointer_array_set_item(trig->subscribed_data, j, NULL);
}
}
OBJ_RELEASE(trig->subscribed_data);
}
if (NULL != trig->counters) {
cntrs = (orte_gpr_replica_counter_t**)((trig->counters)->addr);
for (i=0; i < (trig->counters)->size; i++) {
if (NULL != cntrs[i]) {
j = i;
OBJ_RELEASE(cntrs[i]);
orte_pointer_array_set_item(trig->counters, j, NULL);
}
}
OBJ_RELEASE(trig->counters);
}
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_triggers_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_trigger_construct, /* constructor */
orte_gpr_replica_trigger_destructor); /* destructor */
/* ACTION_TAKEN */
/* constructor - used to initialize state of action_take instance */
static void orte_gpr_replica_action_taken_construct(orte_gpr_replica_action_taken_t* ptr)
{
ptr->action = ORTE_GPR_REPLICA_NO_ACTION;
ptr->seg = NULL;
ptr->cptr = NULL;
ptr->iptr = NULL;
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_action_taken_destructor(orte_gpr_replica_action_taken_t* ptr)
{
/* since we did a "RETAIN" on the objects pointed to by this object,
* we need to "RELEASE" them to indicate we are done with them
*/
if (NULL != ptr->seg) OBJ_RELEASE(ptr->seg);
if (NULL != ptr->cptr) OBJ_RELEASE(ptr->cptr);
if (NULL != ptr->iptr) OBJ_RELEASE(ptr->iptr);
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_action_taken_t, /* type name */
ompi_object_t, /* parent "class" name */
orte_gpr_replica_action_taken_construct, /* constructor */
orte_gpr_replica_action_taken_destructor); /* destructor */
/* NOTIFY MSG LIST */
/* constructor - used to initialize state of notify msg list instance */
static void orte_gpr_replica_notify_msg_list_construct(orte_gpr_replica_notify_msg_list_t* msg)
{
msg->message = NULL;
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_notify_msg_list_destructor(orte_gpr_replica_notify_msg_list_t* msg)
{
if (NULL != msg->message) {
OBJ_RELEASE(msg->message);
}
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_notify_msg_list_t, /* type name */
ompi_list_item_t, /* parent "class" name */
orte_gpr_replica_notify_msg_list_construct, /* constructor */
orte_gpr_replica_notify_msg_list_destructor); /* destructor */
/* CALLBACKS */
/* constructor - used to initialize state of callback list instance */
static void orte_gpr_replica_callbacks_construct(orte_gpr_replica_callbacks_t* cb)
{
OBJ_CONSTRUCT(&(cb->messages), ompi_list_t);
cb->requestor = NULL;
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_callbacks_destructor(orte_gpr_replica_callbacks_t* cb)
{
orte_gpr_replica_notify_msg_list_t *msg;
if (NULL != cb->requestor) {
free(cb->requestor);
cb->requestor = NULL;
}
if (0 < ompi_list_get_size(&(cb->messages))) {
while (NULL != (msg = (orte_gpr_replica_notify_msg_list_t*)ompi_list_remove_first(&(cb->messages)))) {
OBJ_RELEASE(msg);
}
}
OBJ_DESTRUCT(&(cb->messages));
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_callbacks_t, /* type name */
ompi_list_item_t, /* parent "class" name */
orte_gpr_replica_callbacks_construct, /* constructor */
orte_gpr_replica_callbacks_destructor); /* destructor */
/* REPLICA LIST - NOT IMPLEMENTED YET! */
/* constructor - used to initialize state of replica list instance */
static void orte_gpr_replica_list_construct(orte_gpr_replica_list_t* replica)
{
replica->replica = NULL;
}
/* destructor - used to free any resources held by instance */
static void orte_gpr_replica_list_destructor(orte_gpr_replica_list_t* replica)
{
if (NULL != replica->replica) {
free(replica->replica);
replica->replica = NULL;
}
}
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_list_t, /* type name */
ompi_list_item_t, /* parent "class" name */
orte_gpr_replica_list_construct, /* constructor */
orte_gpr_replica_list_destructor); /* destructor */
/* WRITE INVALIDATE - NOT IMPLEMENTED YET! */
/* define instance of ompi_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_replica_write_invalidate_t, /* type name */
ompi_list_item_t, /* parent "class" name */
NULL, /* constructor */
NULL); /* destructor */
int orte_gpr_replica_open(void) int orte_gpr_replica_open(void)
{ {
@ -557,66 +171,92 @@ orte_gpr_base_module_t *orte_gpr_replica_init(bool *allow_multi_user_threads, bo
if (NULL == orte_process_info.gpr_replica_uri) { if (NULL == orte_process_info.gpr_replica_uri) {
/* Return a module (choose an arbitrary, positive priority -- /* Return a module (choose an arbitrary, positive priority --
it's only relevant compared to other ns components). If it's only relevant compared to other ns components). If
we're not the seed, then we don't want to be selected, so we're not the seed, then we don't want to be selected, so
return NULL. */ 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, ompi_mutex_t);
/* initialize the registry head */
if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica.segments),
orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size))) {
ORTE_ERROR_LOG(rc);
return NULL;
}
orte_gpr_replica.num_segs = 0;
*priority = 50; if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica.triggers),
orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size))) {
ORTE_ERROR_LOG(rc);
return NULL;
}
orte_gpr_replica.num_trigs = 0;
/* We allow multi user threads but don't have any hidden threads */ if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica.subscriptions),
orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size))) {
ORTE_ERROR_LOG(rc);
return NULL;
}
orte_gpr_replica.num_subs = 0;
*allow_multi_user_threads = true; /* initialize the callback list head */
*have_hidden_threads = false; OBJ_CONSTRUCT(&orte_gpr_replica.callbacks, ompi_list_t);
orte_gpr_replica.processing_callbacks = false;
/* setup the thread locks and condition variables */
OBJ_CONSTRUCT(&orte_gpr_replica_globals.mutex, ompi_mutex_t); /* initialize the local subscription and trigger trackers */
OBJ_CONSTRUCT(&orte_gpr_replica_globals.wait_for_compound_mutex, ompi_mutex_t); if (ORTE_SUCCESS != (rc = orte_pointer_array_init(
OBJ_CONSTRUCT(&orte_gpr_replica_globals.compound_cmd_condition, ompi_condition_t); &(orte_gpr_replica_globals.local_subscriptions),
orte_gpr_replica_globals.block_size,
/* initialize the registry compound mode */ orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.compound_cmd_mode = false; orte_gpr_replica_globals.block_size))) {
orte_gpr_replica_globals.exec_compound_cmd_mode = false; ORTE_ERROR_LOG(rc);
orte_gpr_replica_globals.compound_cmd_waiting = 0; return NULL;
orte_gpr_replica_globals.compound_cmd = NULL; }
orte_gpr_replica_globals.num_local_subs = 0;
/* initialize the registry head */ orte_gpr_replica_globals.trig_cntr = 0;
if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica.segments),
orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size))) {
ORTE_ERROR_LOG(rc);
return NULL;
}
if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica.triggers),
orte_gpr_replica_globals.block_size,
orte_gpr_replica_globals.max_size,
orte_gpr_replica_globals.block_size))) {
ORTE_ERROR_LOG(rc);
return NULL;
}
/* initialize the callback list head */
OBJ_CONSTRUCT(&orte_gpr_replica.callbacks, ompi_list_t);
orte_gpr_replica.processing_callbacks = false;
/* initialize the search arrays for temporarily storing search results */ /* 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_replica_globals.max_size, 100))) {
ORTE_ERROR_LOG(rc);
return NULL;
}
if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica_globals.srch_cptr), if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica_globals.srch_cptr),
100, orte_gpr_replica_globals.max_size, 100))) { 100, orte_gpr_replica_globals.max_size, 100))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return NULL; return NULL;
} }
orte_gpr_replica_globals.num_srch_cptr = 0;
if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica_globals.srch_ival), if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica_globals.srch_ival),
100, orte_gpr_replica_globals.max_size, 100))) { 100, orte_gpr_replica_globals.max_size, 100))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return NULL; return NULL;
} }
orte_gpr_replica_globals.num_srch_ival = 0;
if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica_globals.acted_upon), if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica_globals.acted_upon),
100, orte_gpr_replica_globals.max_size, 100))) { 100, orte_gpr_replica_globals.max_size, 100))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return NULL; return NULL;
} }
orte_gpr_replica_globals.num_acted_upon = 0;
if (ORTE_SUCCESS != (rc = orte_bitmap_init(&(orte_gpr_replica_globals.srch_itag), 64))) { if (ORTE_SUCCESS != (rc = orte_bitmap_init(&(orte_gpr_replica_globals.srch_itag), 64))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
@ -658,7 +298,7 @@ int orte_gpr_replica_finalize(void)
{ {
size_t i, j; size_t i, j;
orte_gpr_replica_segment_t** seg; orte_gpr_replica_segment_t** seg;
orte_gpr_replica_triggers_t** trig; orte_gpr_replica_trigger_t** trig;
orte_gpr_replica_callbacks_t* cb; orte_gpr_replica_callbacks_t* cb;
if (orte_gpr_replica_globals.debug) { if (orte_gpr_replica_globals.debug) {
@ -666,21 +306,21 @@ int orte_gpr_replica_finalize(void)
} }
seg = (orte_gpr_replica_segment_t**)(orte_gpr_replica.segments)->addr; seg = (orte_gpr_replica_segment_t**)(orte_gpr_replica.segments)->addr;
for (i=0; i < (orte_gpr_replica.segments)->size; i++) { for (i=0, j=0; j < orte_gpr_replica.num_segs &&
i < (orte_gpr_replica.segments)->size; i++) {
if (NULL != seg[i]) { if (NULL != seg[i]) {
j = i; j++;
OBJ_RELEASE(seg[i]); OBJ_RELEASE(seg[i]);
orte_pointer_array_set_item(orte_gpr_replica.segments, j, NULL);
} }
} }
OBJ_RELEASE(orte_gpr_replica.segments); OBJ_RELEASE(orte_gpr_replica.segments);
trig = (orte_gpr_replica_triggers_t**)(orte_gpr_replica.triggers)->addr; trig = (orte_gpr_replica_trigger_t**)(orte_gpr_replica.triggers)->addr;
for (i=0; i < (orte_gpr_replica.triggers)->size; i++) { for (i=0, j=0; j < orte_gpr_replica.num_trigs &&
i < (orte_gpr_replica.triggers)->size; i++) {
if (NULL != trig[i]) { if (NULL != trig[i]) {
j = i; j++;
OBJ_RELEASE(trig[i]); OBJ_RELEASE(trig[i]);
orte_pointer_array_set_item(orte_gpr_replica.triggers, j, NULL);
} }
} }
OBJ_RELEASE(orte_gpr_replica.triggers); OBJ_RELEASE(orte_gpr_replica.triggers);
@ -692,9 +332,6 @@ int orte_gpr_replica_finalize(void)
/* clean up the globals */ /* clean up the globals */
if (NULL != orte_gpr_replica_globals.compound_cmd) {
OBJ_RELEASE(orte_gpr_replica_globals.compound_cmd);
}
if (NULL != orte_gpr_replica_globals.srch_cptr) { if (NULL != orte_gpr_replica_globals.srch_cptr) {
OBJ_RELEASE(orte_gpr_replica_globals.srch_cptr); OBJ_RELEASE(orte_gpr_replica_globals.srch_cptr);

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

@ -37,7 +37,7 @@ static orte_ns_nds_t orte_ns_nds[] = {
int orte_ns_base_set_my_name(void) int orte_ns_base_set_my_name(void)
{ {
int rc, id; int rc, id, flag;
char *mode; char *mode;
orte_vpid_t vpid; orte_vpid_t vpid;
@ -50,9 +50,14 @@ int orte_ns_base_set_my_name(void)
/* first check if we are seed or singleton that couldn't /* first check if we are seed or singleton that couldn't
* join an existing universe - if so, name is mandated, and we need * join an existing universe - if so, name is mandated, and we need
* to set the singleton flag so that our job infrastructure gets built */ * to set the singleton flag so that our job infrastructure gets built
*/
if (orte_process_info.seed || NULL == orte_process_info.ns_replica) { if (orte_process_info.seed || NULL == orte_process_info.ns_replica) {
orte_process_info.singleton = true; id = mca_base_param_register_int("orte", "base", "infrastructure", NULL, (int)false);
mca_base_param_lookup_int(id, &flag);
if (!flag) {
orte_process_info.singleton = true;
}
return orte_ns_base_create_process_name( return orte_ns_base_create_process_name(
&(orte_process_info.my_name), 0, 0, 0); &(orte_process_info.my_name), 0, 0, 0);
} }

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

@ -88,7 +88,7 @@ static void mca_oob_tcp_accept(void);
struct mca_oob_tcp_subscription_t { struct mca_oob_tcp_subscription_t {
ompi_list_item_t item; ompi_list_item_t item;
orte_jobid_t jobid; orte_jobid_t jobid;
orte_gpr_notify_id_t subid; orte_gpr_subscription_id_t subid;
}; };
typedef struct mca_oob_tcp_subscription_t mca_oob_tcp_subscription_t; typedef struct mca_oob_tcp_subscription_t mca_oob_tcp_subscription_t;
@ -611,7 +611,7 @@ int mca_oob_tcp_resolve(mca_oob_tcp_peer_t* peer)
{ {
mca_oob_tcp_addr_t* addr; mca_oob_tcp_addr_t* addr;
mca_oob_tcp_subscription_t* subscription; mca_oob_tcp_subscription_t* subscription;
orte_gpr_value_t trig, *trigs; orte_gpr_trigger_t trig, *trigs;
orte_gpr_subscription_t sub, *subs; orte_gpr_subscription_t sub, *subs;
ompi_list_item_t* item; ompi_list_item_t* item;
int rc; int rc;
@ -638,87 +638,110 @@ int mca_oob_tcp_resolve(mca_oob_tcp_peer_t* peer)
} }
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t); OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
sub.addr_mode = ORTE_GPR_TOKENS_OR | ORTE_GPR_KEYS_OR; /* indicate that this is a standard subscription. This indicates that the
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(sub.segment), peer->peer_name.jobid))) { * 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_OOB_SUBSCRIPTION, peer->peer_name.jobid))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
sub.num_tokens= 0; /* send data when trigger fires, continue to monitor. The default
sub.tokens = NULL; * action for any subscription that includes a trigger condition is
sub.num_keys = 1; * to send the specified data when the trigger fires. This set of flags
sub.keys = (char**)malloc(sizeof(char*)); * indicates that - AFTER the trigger fires - the subscription should
if(NULL == sub.keys) { * 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); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
sub.keys[0] = strdup("oob-tcp"); sub.values[0] = OBJ_NEW(orte_gpr_value_t);
if (NULL == sub.keys[0]) { if (NULL == sub.values[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return 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.cbfunc = mca_oob_tcp_registry_callback;
sub.user_tag = NULL; sub.user_tag = NULL;
/* setup the trigger value */ /* setup the trigger value */
OBJ_CONSTRUCT(&trig, orte_gpr_value_t); OBJ_CONSTRUCT(&trig, orte_gpr_trigger_t);
trig.addr_mode = ORTE_GPR_TOKENS_XAND | ORTE_GPR_KEYS_OR; if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(trig.segment), peer->peer_name.jobid))) { ORTE_STG1_TRIGGER, peer->peer_name.jobid))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&trig);
return rc; return rc;
} }
trig.num_tokens = 1;
trig.tokens = (char**)malloc(sizeof(char*)); /* this is an ORTE-standard trigger that is defined by the ORTE resource manager
if (NULL == trig.tokens) { * when the job was launched - therefore, we don't need to provide any additional
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); * info
return ORTE_ERR_OUT_OF_RESOURCE; */
}
trig.tokens[0] = strdup(ORTE_JOB_GLOBALS);
if (NULL == trig.tokens[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals = (orte_gpr_keyval_t**)malloc(2*sizeof(orte_gpr_keyval_t*));
if(NULL == trig.keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.cnt = 2;
trig.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if(NULL == trig.keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[0]->key = strdup(ORTE_JOB_SLOTS_KEY);
trig.keyvals[0]->type = ORTE_NULL;
trig.keyvals[1] = OBJ_NEW(orte_gpr_keyval_t);
if(NULL == trig.keyvals[1]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[1]->key = strdup(ORTE_PROC_NUM_AT_STG1);
trig.keyvals[1]->type = ORTE_NULL;
trigs = &trig; trigs = &trig;
subs = &sub; subs = &sub;
subscription = OBJ_NEW(mca_oob_tcp_subscription_t); subscription = OBJ_NEW(mca_oob_tcp_subscription_t);
subscription->jobid = peer->peer_name.jobid; subscription->jobid = peer->peer_name.jobid;
rc = orte_gpr.subscribe( rc = orte_gpr.subscribe(1, &subs, 1, &trigs);
ORTE_GPR_NOTIFY_ADD_ENTRY | ORTE_GPR_NOTIFY_VALUE_CHG |
ORTE_GPR_TRIG_CMP_LEVELS | ORTE_GPR_TRIG_ONE_SHOT |
ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG, /* DON'T START NOTIFYING ME ON CHANGES UNTIL AFTER TRIG FIRES */
1, &subs,
1, &trigs,
&subscription->subid);
if(rc != OMPI_SUCCESS) { if(rc != OMPI_SUCCESS) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig); OBJ_DESTRUCT(&trig);
return rc; 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
* here so we can (if desired) cancel that subscription later
*/
subscription->subid = sub.id;
/* done with these, so release any memory */
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig); /* done with these */ OBJ_DESTRUCT(&trig);
ompi_list_append(&mca_oob_tcp_component.tcp_subscriptions, &subscription->item); ompi_list_append(&mca_oob_tcp_component.tcp_subscriptions, &subscription->item);
OMPI_THREAD_UNLOCK(&mca_oob_tcp_component.tcp_lock); OMPI_THREAD_UNLOCK(&mca_oob_tcp_component.tcp_lock);
@ -733,7 +756,8 @@ int mca_oob_tcp_init(void)
{ {
orte_jobid_t jobid; orte_jobid_t jobid;
orte_buffer_t *buffer; orte_buffer_t *buffer;
orte_gpr_value_t trig, *trigs, *value; orte_gpr_trigger_t trig, *trigs;
orte_gpr_value_t *value;
mca_oob_tcp_subscription_t *subscription; mca_oob_tcp_subscription_t *subscription;
orte_gpr_subscription_t sub, *subs; orte_gpr_subscription_t sub, *subs;
int rc; int rc;
@ -779,90 +803,110 @@ int mca_oob_tcp_init(void)
/* setup the subscription description value */ /* setup the subscription description value */
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t); OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
sub.addr_mode = ORTE_GPR_TOKENS_OR | ORTE_GPR_KEYS_OR; /* indicate that this is a standard subscription. This indicates that the
if (ORTE_SUCCESS != (rc = orte_ns.get_jobid(&jobid, orte_process_info.my_name))) { * 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_OOB_SUBSCRIPTION, jobid))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(sub.segment), jobid))) { /* 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;
}
/* define the segment */
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(
&(sub.values[0]->segment),
jobid))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub);
return rc; return rc;
} }
sub.num_tokens= 0; sub.values[0]->addr_mode = ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR;
sub.tokens = NULL; /* look at all containers on this segment */
sub.num_keys = 1; sub.values[0]->tokens = NULL;
sub.keys = (char**)malloc(sizeof(char*)); sub.values[0]->num_tokens = 0;
if(NULL == sub.keys) { /* 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); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
sub.keys[0] = strdup("oob-tcp"); sub.values[0]->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == sub.keys[0]) { if (NULL == sub.values[0]->keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE; 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.cbfunc = mca_oob_tcp_registry_callback;
sub.user_tag = NULL; sub.user_tag = NULL;
/* setup the trigger value */ /* setup the trigger value */
OBJ_CONSTRUCT(&trig, orte_gpr_value_t); OBJ_CONSTRUCT(&trig, orte_gpr_trigger_t);
trig.addr_mode = ORTE_GPR_TOKENS_XAND | ORTE_GPR_KEYS_OR; if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(trig.segment), jobid))) { ORTE_STG1_TRIGGER, jobid))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&value);
OBJ_DESTRUCT(&trig);
return rc; return rc;
} }
trig.num_tokens = 1;
trig.tokens = (char**)malloc(sizeof(char*)); /* this is an ORTE-standard trigger that is defined by the ORTE resource manager
if (NULL == trig.tokens) { * when the job was launched - therefore, we don't need to provide any additional
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); * info
return ORTE_ERR_OUT_OF_RESOURCE; */
}
trig.tokens[0] = strdup(ORTE_JOB_GLOBALS);
if (NULL == trig.tokens[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals = (orte_gpr_keyval_t**)malloc(2*sizeof(orte_gpr_keyval_t*));
if(NULL == trig.keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.cnt = 2;
trig.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if(NULL == trig.keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[0]->key = strdup(ORTE_JOB_SLOTS_KEY);
trig.keyvals[0]->type = ORTE_NULL;
trig.keyvals[1] = OBJ_NEW(orte_gpr_keyval_t);
if(NULL == trig.keyvals[1]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[1]->key = strdup(ORTE_PROC_NUM_AT_STG1);
trig.keyvals[1]->type = ORTE_NULL;
trigs = &trig; trigs = &trig;
subs = &sub; subs = &sub;
rc = orte_gpr.subscribe( subscription = OBJ_NEW(mca_oob_tcp_subscription_t);
ORTE_GPR_NOTIFY_ADD_ENTRY | ORTE_GPR_NOTIFY_VALUE_CHG | subscription->jobid = jobid;
ORTE_GPR_TRIG_CMP_LEVELS | ORTE_GPR_TRIG_ONE_SHOT | rc = orte_gpr.subscribe(1, &subs, 1, &trigs);
ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG,
1, &subs,
1, &trigs,
&subscription->subid);
if(rc != OMPI_SUCCESS) { if(rc != OMPI_SUCCESS) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig); OBJ_DESTRUCT(&trig);
return rc; 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
* here so we can (if desired) cancel that subscription later
*/
subscription->subid = sub.id;
/* done with these, so release any memory */
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig); /* done with these */ OBJ_DESTRUCT(&trig);
buffer = OBJ_NEW(orte_buffer_t); buffer = OBJ_NEW(orte_buffer_t);
if(buffer == NULL) { if(buffer == NULL) {

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

@ -88,7 +88,7 @@ extern "C" {
OMPI_DECLSPEC int orte_pls_base_finalize(void); OMPI_DECLSPEC int orte_pls_base_finalize(void);
OMPI_DECLSPEC int orte_pls_base_close(void); OMPI_DECLSPEC int orte_pls_base_close(void);
/** /**
* Utility routine to get/set proces pid * Utility routine to get/set procesS pid
*/ */
OMPI_DECLSPEC int orte_pls_base_set_proc_pid(const orte_process_name_t*, pid_t); OMPI_DECLSPEC int orte_pls_base_set_proc_pid(const orte_process_name_t*, pid_t);
OMPI_DECLSPEC int orte_pls_base_get_proc_pid(const orte_process_name_t*, pid_t*); OMPI_DECLSPEC int orte_pls_base_get_proc_pid(const orte_process_name_t*, pid_t*);
@ -102,6 +102,11 @@ extern "C" {
OMPI_DECLSPEC int orte_pls_base_set_node_pid(orte_cellid_t cellid, char* node_name, orte_jobid_t jobid, pid_t pid); OMPI_DECLSPEC int orte_pls_base_set_node_pid(orte_cellid_t cellid, char* node_name, orte_jobid_t jobid, pid_t pid);
OMPI_DECLSPEC int orte_pls_base_get_node_pids(orte_jobid_t jobid, pid_t** pids, size_t* num_pids); OMPI_DECLSPEC int orte_pls_base_get_node_pids(orte_jobid_t jobid, pid_t** pids, size_t* num_pids);
/**
* Utility routine to set progress engine schedule
*/
OMPI_DECLSPEC int orte_pls_base_set_progress_sched(int sched);
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
} }
#endif #endif

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

@ -520,6 +520,20 @@ int orte_pls_rsh_launch(orte_jobid_t jobid)
var = mca_base_param_environ_variable("seed",NULL,NULL); var = mca_base_param_environ_variable("seed",NULL,NULL);
ompi_setenv(var, "0", true, &env); ompi_setenv(var, "0", true, &env);
/* set the progress engine schedule for this node.
* if node_slots is set to zero, then we default to
* NOT being oversubscribed
*/
if (node->node_slots > 0 &&
node->node_slots_inuse > node->node_slots) {
var = mca_base_param_environ_variable("mpi", NULL, "yield_when_idle");
ompi_setenv(var, "1", true, &env);
} else {
var = mca_base_param_environ_variable("mpi", NULL, "yield_when_idle");
ompi_setenv(var, "0", true, &env);
}
free(var);
/* exec the daemon */ /* exec the daemon */
execve(exec_path, exec_argv, env); execve(exec_path, exec_argv, env);
ompi_output(0, "orte_pls_rsh: execv failed with errno=%d\n", errno); ompi_output(0, "orte_pls_rsh: execv failed with errno=%d\n", errno);

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

@ -75,8 +75,10 @@ int orte_ras_base_node_query(ompi_list_t* nodes)
NULL, NULL,
&cnt, &cnt,
&values); &values);
if(ORTE_SUCCESS != rc) if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
return rc; return rc;
}
/* parse the response */ /* parse the response */
for(i=0; i<cnt; i++) { for(i=0; i<cnt; i++) {
@ -140,8 +142,10 @@ int orte_ras_base_node_query_alloc(ompi_list_t* nodes, orte_jobid_t jobid)
char* jobid_str; char* jobid_str;
int rc; int rc;
if(ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&jobid_str, jobid))) if(ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&jobid_str, jobid))) {
ORTE_ERROR_LOG(rc);
return rc; return rc;
}
asprintf(&keys[4], "%s-%s", ORTE_NODE_SLOTS_ALLOC_KEY, jobid_str); asprintf(&keys[4], "%s-%s", ORTE_NODE_SLOTS_ALLOC_KEY, jobid_str);
free(jobid_str); free(jobid_str);
@ -153,8 +157,10 @@ int orte_ras_base_node_query_alloc(ompi_list_t* nodes, orte_jobid_t jobid)
keys, keys,
&cnt, &cnt,
&values); &values);
if(ORTE_SUCCESS != rc) if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
return rc; return rc;
}
/* parse the response */ /* parse the response */
for(i=0; i<cnt; i++) { for(i=0; i<cnt; i++) {
@ -307,6 +313,7 @@ int orte_ras_base_node_insert(ompi_list_t* nodes)
/* setup index/keys for this node */ /* setup index/keys for this node */
rc = orte_schema.get_node_tokens(&value->tokens, &value->num_tokens, node->node_cellid, node->node_name); rc = orte_schema.get_node_tokens(&value->tokens, &value->num_tokens, node->node_cellid, node->node_name);
if (ORTE_SUCCESS != rc) { if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
for (j=0; j <= i; j++) { for (j=0; j <= i; j++) {
OBJ_RELEASE(values[j]); OBJ_RELEASE(values[j]);
} }
@ -316,7 +323,9 @@ int orte_ras_base_node_insert(ompi_list_t* nodes)
} }
/* try the insert */ /* try the insert */
rc = orte_gpr.put(num_values, values); if (ORTE_SUCCESS != (rc = orte_gpr.put(num_values, values))) {
ORTE_ERROR_LOG(rc);
}
for (j=0; j < num_values; j++) { for (j=0; j < num_values; j++) {
OBJ_RELEASE(values[j]); OBJ_RELEASE(values[j]);
@ -340,8 +349,10 @@ int orte_ras_base_node_delete(ompi_list_t* nodes)
char* cellid; char* cellid;
char* tokens[3]; char* tokens[3];
if(ORTE_SUCCESS != (rc = orte_ns.convert_cellid_to_string(&cellid, node->node_cellid))) if(ORTE_SUCCESS != (rc = orte_ns.convert_cellid_to_string(&cellid, node->node_cellid))) {
ORTE_ERROR_LOG(rc);
return rc; return rc;
}
/* setup index/keys for this node */ /* setup index/keys for this node */
tokens[0] = node->node_name; tokens[0] = node->node_name;
@ -353,8 +364,10 @@ int orte_ras_base_node_delete(ompi_list_t* nodes)
ORTE_NODE_SEGMENT, ORTE_NODE_SEGMENT,
tokens, tokens,
NULL); NULL);
if(ORTE_SUCCESS != rc) if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
return rc; return rc;
}
} }
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
@ -374,6 +387,7 @@ int orte_ras_base_node_assign(ompi_list_t* nodes, orte_jobid_t jobid)
num_values = ompi_list_get_size(nodes); num_values = ompi_list_get_size(nodes);
if (0 >= num_values) { if (0 >= num_values) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM; return ORTE_ERR_BAD_PARAM;
} }
@ -426,12 +440,15 @@ int orte_ras_base_node_assign(ompi_list_t* nodes, orte_jobid_t jobid)
if(node->node_slots_alloc == 0) if(node->node_slots_alloc == 0)
continue; continue;
if(ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&jobid_str, jobid))) if(ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&jobid_str, jobid))) {
ORTE_ERROR_LOG(rc);
return rc; return rc;
}
/* setup index/keys for this node */ /* setup index/keys for this node */
rc = orte_schema.get_node_tokens(&values[i]->tokens, &values[i]->num_tokens, node->node_cellid, node->node_name); rc = orte_schema.get_node_tokens(&values[i]->tokens, &values[i]->num_tokens, node->node_cellid, node->node_name);
if (ORTE_SUCCESS != rc) { if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
for (j=0; j < num_values; j++) { for (j=0; j < num_values; j++) {
OBJ_RELEASE(values[j]); OBJ_RELEASE(values[j]);
} }
@ -448,7 +465,9 @@ int orte_ras_base_node_assign(ompi_list_t* nodes, orte_jobid_t jobid)
} }
/* try the insert */ /* try the insert */
rc = orte_gpr.put(num_values, values); if (ORTE_SUCCESS != (rc = orte_gpr.put(num_values, values))) {
ORTE_ERROR_LOG(rc);
}
for (j=0; j < num_values; j++) { for (j=0; j < num_values; j++) {
OBJ_RELEASE(values[j]); OBJ_RELEASE(values[j]);

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

@ -39,9 +39,9 @@
int orte_rmgr_base_proc_stage_gate_init(orte_jobid_t job) int orte_rmgr_base_proc_stage_gate_init(orte_jobid_t job)
{ {
size_t i, num_counters=6; size_t i, num_counters=6;
orte_gpr_notify_id_t subnum;
int rc; int rc;
orte_gpr_value_t *values, value, trig, *trigs; orte_gpr_value_t *values, value, trigvalue, *trigvals;
orte_gpr_trigger_t trig, *trigs;
orte_gpr_subscription_t sub, *subs; orte_gpr_subscription_t sub, *subs;
char* keys[] = { char* keys[] = {
/* changes to this ordering need to be reflected in code below */ /* changes to this ordering need to be reflected in code below */
@ -52,6 +52,12 @@ int orte_rmgr_base_proc_stage_gate_init(orte_jobid_t job)
ORTE_PROC_NUM_ABORTED, ORTE_PROC_NUM_ABORTED,
ORTE_PROC_NUM_TERMINATED ORTE_PROC_NUM_TERMINATED
}; };
char* trig_names[] = {
/* changes to this ordering need to be reflected in code below */
ORTE_STG1_TRIGGER,
ORTE_STG2_TRIGGER,
ORTE_STG3_TRIGGER
};
/* setup the counters */ /* setup the counters */
OBJ_CONSTRUCT(&value, orte_gpr_value_t); OBJ_CONSTRUCT(&value, orte_gpr_value_t);
@ -97,193 +103,286 @@ int orte_rmgr_base_proc_stage_gate_init(orte_jobid_t job)
} }
OBJ_DESTRUCT(&value); OBJ_DESTRUCT(&value);
/* for the trigger, we want the counter values returned to us AND /* 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 * information on VPID_START so we can generate the list of peers
* to receive the xcast messages for barrier release. * to receive the xcast messages for barrier release.
* setup subscriptions for that purpose. we'll enter the precise data */
/*** 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, * keys when we are ready to register the subscription - for now,
* do all the basic stuff * do all the basic stuff
*/ */
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t); OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
sub.addr_mode = ORTE_GPR_TOKENS_XAND | ORTE_GPR_KEYS_OR; /* we do not name the subscription - see explanation below. also, we do
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(sub.segment), job))) { * 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))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
return rc; return rc;
} }
sub.tokens = (char**)malloc(sizeof(char*)); /* define the tokens for the container */
if (NULL == sub.tokens) { value.tokens = (char**)malloc(sizeof(char*));
if (NULL == value.tokens) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
sub.tokens[0] = strdup(ORTE_JOB_GLOBALS); /* the counters are in the job's globals container */ value.tokens[0] = strdup(ORTE_JOB_GLOBALS); /* the counters are in the job's globals container */
sub.num_tokens = 1; value.num_tokens = 1;
sub.num_keys = 3; /* define the keys to be returned */
sub.keys = (char**)malloc(sizeof(char*) * sub.num_keys); value.cnt = 3;
if (NULL == sub.keys) { 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); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
sub.keys[1] = strdup(ORTE_JOB_SLOTS_KEY); for (i=0; i < value.cnt; i++) {
sub.keys[2] = strdup(ORTE_JOB_VPID_START_KEY); 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.cbfunc = orte_rmgr_base_proc_stage_gate_mgr;
sub.user_tag = NULL; sub.user_tag = NULL;
/*** TRIGGERS ***/
/* setup the trigger information - initialize the common elements */ /* setup the trigger information - initialize the common elements */
OBJ_CONSTRUCT(&trig, orte_gpr_value_t); OBJ_CONSTRUCT(&trig, orte_gpr_trigger_t);
trig.addr_mode = ORTE_GPR_TOKENS_XAND; /* we WILL name the trig - see explanation below. we do
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(trig.segment), job))) { * 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); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&trig); goto CLEANUP;
return rc;
} }
trig.tokens = (char**)malloc(sizeof(char*)); /* define the tokens for the container */
if (NULL == trig.tokens) { trigvalue.tokens = (char**)malloc(sizeof(char*));
if (NULL == trigvalue.tokens) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub); rc = ORTE_ERR_OUT_OF_RESOURCE;
OBJ_DESTRUCT(&trig); goto CLEANUP;
return ORTE_ERR_OUT_OF_RESOURCE;
} }
trig.tokens[0] = strdup(ORTE_JOB_GLOBALS); trigvalue.tokens[0] = strdup(ORTE_JOB_GLOBALS); /* the counters are in the job's globals container */
trig.num_tokens = 1; trigvalue.num_tokens = 1;
trig.cnt = 2; /* define the keys that identify the counters */
trig.keyvals = (orte_gpr_keyval_t**)malloc(2*sizeof(orte_gpr_keyval_t*)); trigvalue.cnt = 2;
if (NULL == trig.keyvals) { 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); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub); rc = ORTE_ERR_OUT_OF_RESOURCE;
OBJ_DESTRUCT(&trig); goto CLEANUP;
return ORTE_ERR_OUT_OF_RESOURCE;
} }
trig.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t); trigvalue.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trig.keyvals[0]) { if (NULL == trigvalue.keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub); rc = ORTE_ERR_OUT_OF_RESOURCE;
OBJ_DESTRUCT(&trig); goto CLEANUP;
return ORTE_ERR_OUT_OF_RESOURCE;
} }
trig.keyvals[1] = OBJ_NEW(orte_gpr_keyval_t); trigvalue.keyvals[1] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trig.keyvals[1]) { if (NULL == trigvalue.keyvals[1]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub); rc = ORTE_ERR_OUT_OF_RESOURCE;
OBJ_DESTRUCT(&trig); goto CLEANUP;
return ORTE_ERR_OUT_OF_RESOURCE;
} }
/* Now do the individual triggers. /* setup the triggers for the three main stage gates - these all compare
* First, setup the triggers for the three main stage gates - these all compare
* their value to that in ORTE_JOB_SLOTS_KEY * their value to that in ORTE_JOB_SLOTS_KEY
*/ */
trig.keyvals[0]->key = strdup(ORTE_JOB_SLOTS_KEY); trigvalue.keyvals[0]->key = strdup(ORTE_JOB_SLOTS_KEY);
if (NULL == trig.keyvals[0]->key) { if (NULL == trigvalue.keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub); rc = ORTE_ERR_OUT_OF_RESOURCE;
OBJ_DESTRUCT(&trig); goto CLEANUP;
return ORTE_ERR_OUT_OF_RESOURCE;
} }
trig.keyvals[0]->type = ORTE_NULL; /* we don't need to define the type and value for the keyvals - the subscribe
trig.keyvals[1]->type = ORTE_NULL; * function ignores those fields
*/
/* do the three stage gate subscriptions. /* do the three stage gate subscriptions.
*/ */
for (i=0; i < 3; i++) { for (i=0; i < 3; i++) {
sub.keys[0] = strdup(keys[i]); /*
if (NULL == sub.keys[0]) { * 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); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub); rc = ORTE_ERR_OUT_OF_RESOURCE;
OBJ_DESTRUCT(&trig); goto CLEANUP;
return ORTE_ERR_OUT_OF_RESOURCE;
} }
trig.keyvals[1]->key = strdup(keys[i]); /*
if (NULL == trig.keyvals[1]->key) { * 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_names[i], job))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
trigvalue.keyvals[1]->key = strdup(keys[i]);
if (NULL == trigvalue.keyvals[1]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub); rc = ORTE_ERR_OUT_OF_RESOURCE;
OBJ_DESTRUCT(&trig); goto CLEANUP;
return ORTE_ERR_OUT_OF_RESOURCE;
} }
subs = &sub; subs = &sub;
trigs = &trig; trigs = &trig;
rc = orte_gpr.subscribe( rc = orte_gpr.subscribe(
ORTE_GPR_TRIG_ALL_CMP,
1, &subs, 1, &subs,
1, &trigs, 1, &trigs);
&subnum);
if(ORTE_SUCCESS != rc) { if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub); goto CLEANUP;
OBJ_DESTRUCT(&trig);
return rc;
} }
free(sub.keys[0]); free(value.keyvals[0]->key);
sub.keys[0] = NULL; value.keyvals[0]->key = NULL;
free(trig.keyvals[1]->key); free(trig.name);
trig.keyvals[1]->key = NULL; free(trigvalue.keyvals[1]->key);
trigvalue.keyvals[1]->key = NULL;
} }
/* Next, setup the trigger that watches the NUM_ABORTED counter to see if /* 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 * 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 * so it can in turn order the job to be aborted
*/ */
sub.cbfunc = orte_rmgr_base_proc_stage_gate_mgr_abort; sub.cbfunc = orte_rmgr_base_proc_stage_gate_mgr_abort;
sub.keys[0] = strdup(ORTE_PROC_NUM_ABORTED); value.keyvals[0]->key = strdup(ORTE_PROC_NUM_ABORTED);
if (NULL == sub.keys[0]) { if (NULL == value.keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub); rc = ORTE_ERR_OUT_OF_RESOURCE;
OBJ_DESTRUCT(&trig); goto CLEANUP;
return ORTE_ERR_OUT_OF_RESOURCE;
} }
OBJ_RELEASE(trig.keyvals[0]); /* set the trigger name */
OBJ_RELEASE(trig.keyvals[1]); if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
free(trig.keyvals); ORTE_NUM_ABORTED_TRIGGER, job))) {
trig.cnt = 1; ORTE_ERROR_LOG(rc);
trig.keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t**)); goto CLEANUP;
if (NULL == trig.keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
} }
trig.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t); /* set the trigger action to fire at a specified level */
if (NULL == trig.keyvals[0]) { 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); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub); rc = ORTE_ERR_OUT_OF_RESOURCE;
OBJ_DESTRUCT(&trig); goto CLEANUP;
return ORTE_ERR_OUT_OF_RESOURCE;
} }
trig.keyvals[0]->key = strdup(ORTE_PROC_NUM_ABORTED); trigvalue.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trig.keyvals[0]->key) { if (NULL == trigvalue.keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub); rc = ORTE_ERR_OUT_OF_RESOURCE;
OBJ_DESTRUCT(&trig); goto CLEANUP;
return ORTE_ERR_OUT_OF_RESOURCE;
} }
trig.keyvals[0]->type = ORTE_SIZE; trigvalue.keyvals[0]->key = strdup(ORTE_PROC_NUM_ABORTED);
trig.keyvals[0]->value.size = 1; /* trigger on the first process that aborts */ 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; subs = &sub;
trigs = &trig; trigs = &trig;
rc = orte_gpr.subscribe( rc = orte_gpr.subscribe(
ORTE_GPR_TRIG_ALL_AT,
1, &subs, 1, &subs,
1, &trigs, 1, &trigs);
&subnum);
if (ORTE_SUCCESS != rc) { if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub); }
OBJ_DESTRUCT(&trig);
return rc;
}
OBJ_DESTRUCT(&sub); CLEANUP:
OBJ_DESTRUCT(&trigvalue);
trig.values = NULL;
OBJ_DESTRUCT(&trig); OBJ_DESTRUCT(&trig);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return ORTE_SUCCESS; return rc;
} }
@ -300,8 +399,15 @@ void orte_rmgr_base_proc_stage_gate_mgr(orte_gpr_notify_data_t *data,
orte_buffer_t msg; orte_buffer_t msg;
orte_jobid_t job; orte_jobid_t job;
/* get the jobid from the segment name */ /* get the jobid from the segment name
if (ORTE_SUCCESS != (rc = orte_schema.extract_jobid_from_segment_name(&job, data->segment))) { * 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 = data->values;
if (ORTE_SUCCESS != (rc =
orte_schema.extract_jobid_from_segment_name(&job,
values[0]->segment))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return; return;
} }
@ -375,11 +481,19 @@ void orte_rmgr_base_proc_stage_gate_mgr(orte_gpr_notify_data_t *data,
void orte_rmgr_base_proc_stage_gate_mgr_abort(orte_gpr_notify_data_t *data, void orte_rmgr_base_proc_stage_gate_mgr_abort(orte_gpr_notify_data_t *data,
void *user_tag) void *user_tag)
{ {
orte_gpr_value_t **values;
orte_jobid_t job; orte_jobid_t job;
int rc; int rc;
/* get the jobid from the segment name */ /* get the jobid from the segment name
if (ORTE_SUCCESS != (rc = orte_schema.extract_jobid_from_segment_name(&job, data->segment))) { * 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 = data->values;
if (ORTE_SUCCESS != (rc =
orte_schema.extract_jobid_from_segment_name(&job,
values[0]->segment))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return; return;
} }
@ -394,9 +508,10 @@ void orte_rmgr_base_proc_stage_gate_mgr_abort(orte_gpr_notify_data_t *data,
int orte_rmgr_base_proc_stage_gate_subscribe(orte_jobid_t job, orte_gpr_notify_cb_fn_t cbfunc, void* cbdata) int orte_rmgr_base_proc_stage_gate_subscribe(orte_jobid_t job, orte_gpr_notify_cb_fn_t cbfunc, void* cbdata)
{ {
size_t i, sub_num; size_t i;
int rc; int rc;
orte_gpr_value_t trig, *trigs; orte_gpr_value_t value, *values;
orte_gpr_trigger_t trig, *trigs;
orte_gpr_subscription_t sub, *subs; orte_gpr_subscription_t sub, *subs;
char* keys[] = { char* keys[] = {
/* changes to this ordering need to be reflected in code below */ /* changes to this ordering need to be reflected in code below */
@ -406,175 +521,168 @@ int orte_rmgr_base_proc_stage_gate_subscribe(orte_jobid_t job, orte_gpr_notify_c
ORTE_PROC_NUM_FINALIZED, ORTE_PROC_NUM_FINALIZED,
ORTE_PROC_NUM_TERMINATED ORTE_PROC_NUM_TERMINATED
}; };
char* trig_names[] = {
/* changes to this ordering need to be reflected in code below
* number of entries MUST match those above
*/
ORTE_STG1_TRIGGER,
ORTE_STG2_TRIGGER,
ORTE_STG3_TRIGGER,
ORTE_NUM_FINALIZED_TRIGGER,
ORTE_NUM_TERMINATED_TRIGGER
};
size_t num_counters = sizeof(keys)/sizeof(keys[0]); size_t num_counters = sizeof(keys)/sizeof(keys[0]);
/* for the trigger, we want the counter values returned to us /*** SUBSCRIPTIONS ***/
* setup subscriptions for that purpose. we'll enter the precise data /* 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, * keys when we are ready to register the subscription - for now,
* do all the basic stuff * do all the basic stuff
*/ */
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t); OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
sub.addr_mode = ORTE_GPR_TOKENS_XAND | ORTE_GPR_KEYS_OR; /* we do not name the subscription - see explanation below. also, we do
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(sub.segment), job))) { * 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))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
return rc; return rc;
} }
sub.tokens = (char**)malloc(sizeof(char*)); /* define the tokens for the container */
if (NULL == sub.tokens) { value.tokens = (char**)malloc(sizeof(char*));
if (NULL == value.tokens) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
sub.tokens[0] = strdup(ORTE_JOB_GLOBALS); /* the counters are in the job's globals container */ value.tokens[0] = strdup(ORTE_JOB_GLOBALS); /* the counters are in the job's globals container */
sub.num_tokens = 1; value.num_tokens = 1;
sub.keys = (char**)malloc(sizeof(char*)*1); /* the keys describing the data to be returned will be defined later
if (NULL == sub.keys) { * 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); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub); OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
sub.num_keys = 1; 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.cbfunc = cbfunc;
sub.user_tag = cbdata; sub.user_tag = cbdata;
/*** TRIGGERS ***/
/* setup the trigger information - initialize the common elements */ /* setup the trigger information - initialize the common elements */
OBJ_CONSTRUCT(&trig, orte_gpr_value_t); OBJ_CONSTRUCT(&trig, orte_gpr_trigger_t);
trig.addr_mode = ORTE_GPR_TOKENS_XAND; /* since the named triggers have already been defined, we don't need
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(trig.segment), job))) { * to replicate that here! all we need to do is refer to the
ORTE_ERROR_LOG(rc); * proper trigger name - we'll do that below
OBJ_DESTRUCT(&trig);
return rc;
}
trig.tokens = (char**)malloc(sizeof(char*));
if (NULL == trig.tokens) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.tokens[0] = strdup(ORTE_JOB_GLOBALS);
trig.num_tokens = 1;
trig.cnt = 2;
trig.keyvals = (orte_gpr_keyval_t**)malloc(2*sizeof(orte_gpr_keyval_t*));
if (NULL == trig.keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trig.keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[1] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trig.keyvals[1]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* Now do the individual triggers.
* First, setup the triggers for the three main stage gates - these all compare
* their value to that in ORTE_JOB_SLOTS_KEY
*/ */
trig.keyvals[0]->key = strdup(ORTE_JOB_SLOTS_KEY); trig.action = ORTE_GPR_TRIG_ALL_CMP;
if (NULL == trig.keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); /* do the trigger subscriptions */
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[0]->type = ORTE_NULL;
trig.keyvals[1]->type = ORTE_NULL;
/* do the counter subscriptions. */
for (i=0; i < num_counters; i++) { for (i=0; i < num_counters; i++) {
sub.keys[0] = strdup(keys[i]); /* insert the subscription key identifying the data to
if (NULL == sub.keys[0]) { * 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); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub); rc = ORTE_ERR_OUT_OF_RESOURCE;
OBJ_DESTRUCT(&trig); goto CLEANUP;
return ORTE_ERR_OUT_OF_RESOURCE;
} }
trig.keyvals[1]->key = strdup(keys[i]); /* get the standard trigger name to which we are "attaching" */
if (NULL == trig.keyvals[1]->key) { if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); trig_names[i], job))) {
OBJ_DESTRUCT(&sub); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&trig); goto CLEANUP;
return ORTE_ERR_OUT_OF_RESOURCE;
} }
subs = &sub; subs = &sub;
trigs = &trig; trigs = &trig;
rc = orte_gpr.subscribe( rc = orte_gpr.subscribe(
ORTE_GPR_TRIG_ALL_CMP,
1, &subs, 1, &subs,
1, &trigs, 1, &trigs);
&sub_num);
if(ORTE_SUCCESS != rc) { if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub); goto CLEANUP;
OBJ_DESTRUCT(&trig);
return rc;
} }
free(sub.keys[0]); free(value.keyvals[0]->key);
sub.keys[0] = NULL; value.keyvals[0]->key = NULL;
free(trig.keyvals[1]->key); free(trig.name);
trig.keyvals[1]->key = NULL; trig.name = NULL;
} }
/* Now do the abort trigger */ /* Now do the abort trigger.
sub.keys[0] = strdup(ORTE_PROC_NUM_ABORTED); * setup the subscription to return the number aborted\
if (NULL == sub.keys[0]) { */
value.keyvals[0]->key = strdup(ORTE_PROC_NUM_ABORTED);
if (NULL == value.keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub); rc = ORTE_ERR_OUT_OF_RESOURCE;
OBJ_DESTRUCT(&trig); goto CLEANUP;
return ORTE_ERR_OUT_OF_RESOURCE;
} }
OBJ_RELEASE(trig.keyvals[0]);
OBJ_RELEASE(trig.keyvals[1]); /* set the trigger action */
free(trig.keyvals); trig.action = ORTE_GPR_TRIG_ALL_AT;
trig.cnt = 1; /* get the standard "abort" trigger name */
trig.keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t**)); if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
if (NULL == trig.keyvals) { ORTE_NUM_ABORTED_TRIGGER, job))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub); goto CLEANUP;
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
} }
trig.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trig.keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[0]->key = strdup(ORTE_PROC_NUM_ABORTED);
if (NULL == trig.keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[0]->type = ORTE_SIZE;
trig.keyvals[0]->value.size = 1; /* trigger on the first process that aborts */
subs = &sub; subs = &sub;
trigs = &trig; trigs = &trig;
rc = orte_gpr.subscribe( rc = orte_gpr.subscribe(
ORTE_GPR_TRIG_ALL_AT,
1, &subs, 1, &subs,
1, &trigs, 1, &trigs);
&sub_num);
if (ORTE_SUCCESS != rc) { if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
} }
OBJ_DESTRUCT(&sub); CLEANUP:
OBJ_DESTRUCT(&trig); OBJ_DESTRUCT(&trig);
return ORTE_SUCCESS; OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return rc;
} }

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

@ -235,16 +235,21 @@ static int orte_rmgr_proxy_terminate_proc(const orte_process_name_t* proc_name)
static void orte_rmgr_proxy_callback(orte_gpr_notify_data_t *data, void *cbdata) static void orte_rmgr_proxy_callback(orte_gpr_notify_data_t *data, void *cbdata)
{ {
orte_rmgr_cb_fn_t cbfunc = (orte_rmgr_cb_fn_t)cbdata; orte_rmgr_cb_fn_t cbfunc = (orte_rmgr_cb_fn_t)cbdata;
orte_gpr_value_t **values;
orte_gpr_keyval_t** keyvals; orte_gpr_keyval_t** keyvals;
orte_jobid_t jobid; orte_jobid_t jobid;
size_t i, j; size_t i, j;
int rc; int rc;
/* get the jobid from the segment name */ /* we made sure in the subscriptions that at least one
if (ORTE_SUCCESS != (rc = orte_schema.extract_jobid_from_segment_name(&jobid, data->segment))) { * value is always returned
* get the jobid from the segment name in the first value
*/
values = data->values;
if (ORTE_SUCCESS != (rc =
orte_schema.extract_jobid_from_segment_name(&jobid,
values[0]->segment))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
ompi_output(0, "[%lu,%lu,%lu] orte_rmgr_proxy_callback: %s\n",
ORTE_NAME_ARGS(orte_process_info.my_name), data->segment);
return; return;
} }

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

@ -182,13 +182,20 @@ static void orte_rmgr_urm_wireup_stdin(orte_jobid_t jobid)
static void orte_rmgr_urm_callback(orte_gpr_notify_data_t *data, void *cbdata) static void orte_rmgr_urm_callback(orte_gpr_notify_data_t *data, void *cbdata)
{ {
orte_rmgr_cb_fn_t cbfunc = (orte_rmgr_cb_fn_t)cbdata; orte_rmgr_cb_fn_t cbfunc = (orte_rmgr_cb_fn_t)cbdata;
orte_gpr_value_t **values;
orte_gpr_keyval_t** keyvals; orte_gpr_keyval_t** keyvals;
orte_jobid_t jobid; orte_jobid_t jobid;
size_t i, j; size_t i, j;
int rc; int rc;
/* get the jobid from the segment name */ /* we made sure in the subscriptions that at least one
if (ORTE_SUCCESS != (rc = orte_schema.extract_jobid_from_segment_name(&jobid, data->segment))) { * value is always returned
* get the jobid from the segment name in the first value
*/
values = data->values;
if (ORTE_SUCCESS != (rc =
orte_schema.extract_jobid_from_segment_name(&jobid,
values[0]->segment))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return; return;
} }

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

@ -60,6 +60,12 @@ int orte_schema_base_get_cell_tokens(char ***tokens, size_t* num_tokens, orte_ce
int orte_schema_base_get_job_segment_name(char **name, orte_jobid_t jobid); int orte_schema_base_get_job_segment_name(char **name, orte_jobid_t jobid);
int orte_schema_base_extract_jobid_from_segment_name(orte_jobid_t *jobid, char *name); int orte_schema_base_extract_jobid_from_segment_name(orte_jobid_t *jobid, char *name);
int orte_schema_base_store_my_info(void); int orte_schema_base_store_my_info(void);
int orte_schema_base_get_std_trigger_name(char **name,
char *trigger,
orte_jobid_t jobid);
int orte_schema_base_get_std_subscription_name(char **name,
char *subscription,
orte_jobid_t jobid);
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)

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

@ -246,3 +246,46 @@ int orte_schema_base_store_my_info(void)
return rc; return rc;
} }
int orte_schema_base_get_std_trigger_name(char **name,
char *trigger,
orte_jobid_t jobid)
{
char *jobidstring;
int rc;
if (ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&jobidstring, jobid))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (0 > asprintf(name, "%s-%s", trigger, jobidstring)) {
free(jobidstring);
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
free(jobidstring);
return ORTE_SUCCESS;
}
int orte_schema_base_get_std_subscription_name(char **name,
char *subscription,
orte_jobid_t jobid)
{
char *jobidstring;
int rc;
if (ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&jobidstring, jobid))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (0 > asprintf(name, "%s-%s", subscription, jobidstring)) {
free(jobidstring);
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
free(jobidstring);
return ORTE_SUCCESS;
}

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

@ -42,7 +42,9 @@ OMPI_DECLSPEC orte_schema_base_module_t orte_schema = {
orte_schema_base_get_cell_tokens, orte_schema_base_get_cell_tokens,
orte_schema_base_get_job_segment_name, orte_schema_base_get_job_segment_name,
orte_schema_base_extract_jobid_from_segment_name, orte_schema_base_extract_jobid_from_segment_name,
orte_schema_base_store_my_info orte_schema_base_store_my_info,
orte_schema_base_get_std_trigger_name,
orte_schema_base_get_std_subscription_name
}; };

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

@ -53,6 +53,15 @@ typedef int (*orte_schema_extract_jobid_from_segment_name_fn_t)(orte_jobid_t *jo
typedef int (*orte_schema_store_my_info_fn_t)(void); typedef int (*orte_schema_store_my_info_fn_t)(void);
typedef int (*orte_schema_get_std_trigger_name_fn_t)(char **name,
char *trigger,
orte_jobid_t jobid);
typedef int (*orte_schema_get_std_subscription_name_fn_t)(char **name,
char *subscription,
orte_jobid_t jobid);
/* /*
* Ver 1.0.0 * Ver 1.0.0
*/ */
@ -63,6 +72,8 @@ struct orte_schema_base_module_1_0_0_t {
orte_schema_get_job_segment_name_fn_t get_job_segment_name; orte_schema_get_job_segment_name_fn_t get_job_segment_name;
orte_schema_extract_jobid_from_segment_name_fn_t extract_jobid_from_segment_name; orte_schema_extract_jobid_from_segment_name_fn_t extract_jobid_from_segment_name;
orte_schema_store_my_info_fn_t store_my_info; orte_schema_store_my_info_fn_t store_my_info;
orte_schema_get_std_trigger_name_fn_t get_std_trigger_name;
orte_schema_get_std_subscription_name_fn_t get_std_subscription_name;
}; };

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

@ -82,5 +82,14 @@ extern char *orte_error_strings[];
#define ORTE_PROC_NUM_FINALIZED "orte-proc-num-finalized" #define ORTE_PROC_NUM_FINALIZED "orte-proc-num-finalized"
#define ORTE_PROC_NUM_TERMINATED "orte-proc-num-terminated" #define ORTE_PROC_NUM_TERMINATED "orte-proc-num-terminated"
/*
* ORTE-wide names for specific system triggers and subscriptions
*/
#define ORTE_STG1_TRIGGER "orte-stage1"
#define ORTE_STG2_TRIGGER "orte-stage2"
#define ORTE_STG3_TRIGGER "orte-stage3"
#define ORTE_NUM_FINALIZED_TRIGGER "orte-num-finalized"
#define ORTE_NUM_ABORTED_TRIGGER "orte-num-aborted"
#define ORTE_NUM_TERMINATED_TRIGGER "orte-num-terminated"
#endif #endif

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

@ -24,10 +24,6 @@
#include "mca/pml/pml.h" #include "mca/pml/pml.h"
#include "runtime/ompi_progress.h" #include "runtime/ompi_progress.h"
#include "include/constants.h" #include "include/constants.h"
#include "mca/errmgr/errmgr.h"
#include "mca/ns/ns.h"
#include "mca/gpr/gpr.h"
#include "mca/schema/schema.h"
/* /*
* default parameters * default parameters
@ -59,154 +55,6 @@ static long event_progress_counter_reset = 0;
static int32_t event_num_mpi_users = 0; static int32_t event_num_mpi_users = 0;
static void
node_schedule_callback(orte_gpr_notify_data_t *notify_data, void *user_tag)
{
size_t proc_slots = 0;
size_t used_proc_slots = 0;
int param;
size_t i;
/* parse the response */
for(i = 0 ; i < notify_data->cnt ; i++) {
orte_gpr_value_t* value = notify_data->values[i];
size_t k;
for(k = 0 ; k < value->cnt ; k++) {
orte_gpr_keyval_t* keyval = value->keyvals[k];
if(strcmp(keyval->key, ORTE_NODE_SLOTS_KEY) == 0) {
proc_slots = keyval->value.size;
continue;
}
if(strncmp(keyval->key, ORTE_NODE_SLOTS_ALLOC_KEY,
strlen(ORTE_NODE_SLOTS_ALLOC_KEY)) == 0) {
used_proc_slots += keyval->value.size;
continue;
}
}
}
param = mca_base_param_find("mpi", NULL, "yield_when_idle");
mca_base_param_set_int(param, (used_proc_slots <= proc_slots) ? 0 : 1);
}
static int
register_node_schedule_callback(void)
{
orte_gpr_notify_id_t rctag;
orte_gpr_value_t trig, *trigs;
orte_gpr_subscription_t sub, *subs;
orte_jobid_t jobid;
int rc;
char **tokens;
size_t num_tokens;
char *my_name_string;
orte_cellid_t cellid;
/* query our node... */
rc = orte_ns.get_proc_name_string(&my_name_string,
orte_process_info.my_name);
if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
return rc;
}
rc = orte_ns.get_cellid(&cellid, orte_process_info.my_name);
if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
return rc;
}
rc = orte_ns.get_jobid(&jobid, orte_process_info.my_name);
if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
return rc;
}
rc = orte_schema.get_node_tokens(&tokens, &num_tokens,
cellid,
my_name_string);
if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* setup the subscription definition */
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
sub.addr_mode = ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR;
sub.segment = strdup(ORTE_NODE_SEGMENT);
sub.tokens = tokens;
sub.num_tokens = num_tokens;
sub.num_keys = 0;
sub.keys = NULL;
sub.cbfunc = node_schedule_callback;
sub.user_tag = NULL;
/* setup the trigger definition */
OBJ_CONSTRUCT(&trig, orte_gpr_value_t);
trig.addr_mode = ORTE_GPR_TOKENS_XAND;
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(trig.segment), jobid))) {
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return rc;
}
trig.tokens = (char**)malloc(sizeof(char*));
if (NULL == trig.tokens) {
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.tokens[0] = strdup(ORTE_JOB_GLOBALS);
trig.num_tokens = 1;
trig.cnt = 2;
trig.keyvals = (orte_gpr_keyval_t**)malloc(2*sizeof(orte_gpr_keyval_t*));
if (NULL == trig.keyvals) {
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trig.keyvals[0]) {
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[0]->key = strdup(ORTE_JOB_SLOTS_KEY);
trig.keyvals[0]->type = ORTE_NULL;
trig.keyvals[1] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trig.keyvals[1]) {
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig.keyvals[1]->key = strdup(ORTE_PROC_NUM_AT_STG1);
trig.keyvals[1]->type = ORTE_NULL;
/* register the subscription */
subs = &sub;
trigs = &trig;
rc = orte_gpr.subscribe(
ORTE_GPR_TRIG_ALL_CMP,
1, &subs,
1, &trigs,
&rctag);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return OMPI_ERROR;
}
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return OMPI_SUCCESS;
}
/* init the progress engine - called from orte_init */ /* init the progress engine - called from orte_init */
int int
ompi_progress_init(void) ompi_progress_init(void)
@ -225,25 +73,9 @@ ompi_progress_init(void)
} }
/* do all the registration stuff during the compound command */
int int
ompi_progress_mpi_init(void) ompi_progress_mpi_init(void)
{ {
int param, value, rc;
/* call sched yield when oversubscribed. */
param = mca_base_param_find("mpi", NULL, "yield_when_idle");
mca_base_param_lookup_int(param, &value);
if (value < 0) {
/* no default given. Register a callback so that we have a
value when we get to mpi_enable() */
rc = register_node_schedule_callback();
if (OMPI_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
event_num_mpi_users = 0; event_num_mpi_users = 0;
return OMPI_SUCCESS; return OMPI_SUCCESS;
@ -260,9 +92,7 @@ ompi_progress_mpi_enable(void)
mca_base_param_lookup_int(param, &value); mca_base_param_lookup_int(param, &value);
if (value < 0) { if (value < 0) {
/* this should never happen (as mpi_enable should be called /* this should never happen set to 1 if it somehow does */
after the compound command is executed). set to 1 if this
happens */
call_yield = 1; call_yield = 1;
} else { } else {
call_yield = value; call_yield = value;

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

@ -63,6 +63,8 @@ int orte_init_stage1(void)
pid_t pid; pid_t pid;
orte_universe_t univ; orte_universe_t univ;
orte_jobid_t my_jobid; orte_jobid_t my_jobid;
orte_cellid_t my_cellid;
orte_gpr_value_t value, *values;
/* Ensure the system_info structure is instantiated and initialized */ /* Ensure the system_info structure is instantiated and initialized */
if (ORTE_SUCCESS != (ret = orte_sys_info())) { if (ORTE_SUCCESS != (ret = orte_sys_info())) {
@ -356,25 +358,87 @@ int orte_init_stage1(void)
return ret; return ret;
} }
/* if we are a singleton, setup the infrastructure for our job */ /* if we are a singleton or the seed, setup the infrastructure for our job */
if(orte_process_info.singleton) { if(orte_process_info.singleton || orte_process_info.seed) {
if (ORTE_SUCCESS != (ret = orte_ns.get_jobid(&my_jobid, orte_process_info.my_name))) { if (ORTE_SUCCESS != (ret = orte_ns.get_jobid(&my_jobid, orte_process_info.my_name))) {
ORTE_ERROR_LOG(ret); ORTE_ERROR_LOG(ret);
return ret; return ret;
} }
if (ORTE_SUCCESS != (ret = orte_rmgr_base_set_job_slots(my_jobid,1))) { if (ORTE_SUCCESS != (ret = orte_ns.get_cellid(&my_cellid, orte_process_info.my_name))) {
ORTE_ERROR_LOG(ret); ORTE_ERROR_LOG(ret);
return ret; return ret;
} }
if (ORTE_SUCCESS != (ret = orte_rmaps_base_set_vpid_range(my_jobid,0,1))) { if (orte_process_info.singleton) {
ORTE_ERROR_LOG(ret); /* setup a fake node structure - this is required to support
return ret; * the MPI attributes function that is sitting on a trigger
} * waiting for info on available node slots. since we can't
if (ORTE_SUCCESS != (ret = orte_rmgr_base_proc_stage_gate_init(my_jobid))) { * really know that info for a singleton, we make the assumption
ORTE_ERROR_LOG(ret); * that the allocation is unity and place a structure on the
return ret; * registry for it
} *
* THIS ONLY SHOULD BE DONE FOR SINGLETONS - DO NOT DO IT
* FOR ANY OTHER CASE
*/
OBJ_CONSTRUCT(&value, orte_gpr_value_t);
values = &value;
/* define the addressing mode and segment */
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);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc = orte_schema.get_node_tokens(&(value.tokens),
&(value.num_tokens), my_cellid, orte_system_info.nodename))) {
ORTE_ERROR_LOG(rc);
return rc;
}
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);
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);
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);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value.keyvals[0]->type = ORTE_UINT32;
value.keyvals[0]->value.ui32 = 1;
/* put the value on the registry */
if (ORTE_SUCCESS != (ret = orte_gpr.put(1, &values))) {
ORTE_ERROR_LOG(ret);
OBJ_DESTRUCT(&value);
return ret;
}
/* cleanup the mess */
OBJ_DESTRUCT(&value);
}
/* set the rest of the infrastructure */
if (ORTE_SUCCESS != (ret = orte_rmgr_base_set_job_slots(my_jobid,1))) {
ORTE_ERROR_LOG(ret);
return ret;
}
if (ORTE_SUCCESS != (ret = orte_rmaps_base_set_vpid_range(my_jobid,0,1))) {
ORTE_ERROR_LOG(ret);
return ret;
}
if (ORTE_SUCCESS != (ret = orte_rmgr_base_proc_stage_gate_init(my_jobid))) {
ORTE_ERROR_LOG(ret);
return ret;
}
} }
return ORTE_SUCCESS; return ORTE_SUCCESS;

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

@ -277,7 +277,15 @@ int main(int argc, char *argv[])
} }
/* Intialize our Open RTE environment */ /* Intialize our Open RTE environment */
/* first, set the flag telling orte_init that I am NOT a
* singleton, but am "infrastructure" - prevents setting
* up incorrect infrastructure that only a singleton would
* require
*/
id = mca_base_param_register_int("orte", "base", "infrastructure", NULL, 0);
mca_base_param_set_int(id, 1);
/* now call orte_init and setup the RTE */
if (ORTE_SUCCESS != (rc = orte_init())) { if (ORTE_SUCCESS != (rc = orte_init())) {
ompi_show_help("help-orterun.txt", "orterun:init-failure", true, ompi_show_help("help-orterun.txt", "orterun:init-failure", true,
"orte_init()", rc); "orte_init()", rc);

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

@ -1466,33 +1466,47 @@ static bool test13(void)
{ {
orte_buffer_t *bufA; orte_buffer_t *bufA;
int rc; int rc;
size_t i, j, k; size_t i, j, k, m;
orte_gpr_subscription_t *src[NUM_ELEMS]; orte_gpr_subscription_t *src[NUM_ELEMS];
orte_gpr_subscription_t *dst[NUM_ELEMS]; orte_gpr_subscription_t *dst[NUM_ELEMS];
for(i=0; i<NUM_ELEMS; i++) { for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_gpr_subscription_t); src[i] = OBJ_NEW(orte_gpr_subscription_t);
src[i]->addr_mode = (uint16_t) i; if (i % 2) {
src[i]->segment = strdup("test-segment-name"); src[i]->name = strdup("dummy-name");
}
src[i]->id = (orte_gpr_subscription_id_t)i;
/* test value counts of 1 to NUM_ELEMS+1 */
src[i]->cnt = i + 1;
src[i]->values = (orte_gpr_value_t**)malloc(src[i]->cnt * sizeof(orte_gpr_value_t*));
for (k=0; k < src[i]->cnt; k++) {
src[i]->values[k] = OBJ_NEW(orte_gpr_value_t);
src[i]->values[k]->addr_mode = (uint16_t) i;
src[i]->values[k]->segment = strdup("test-segment");
/* test token counts of 0! to NUM_ELEMS */
src[i]->values[k]->num_tokens = i;
if (src[i]->values[k]->num_tokens) { /* if to allow testing of token count of zero */
src[i]->values[k]->tokens = (char**)malloc(src[i]->values[k]->num_tokens * sizeof(char*));
for (j=0; j < src[i]->values[k]->num_tokens; j++) {
src[i]->values[k]->tokens[j] = strdup("test-token");
}
}
/* test token counts of 0! to NUM_ELEMS */ /* test key counts of 0 to NUM_ELEMS */
src[i]->num_tokens = i; src[i]->values[k]->cnt = i;
if (src[i]->num_tokens) { /* if to allow testing of token count of zero */ if (src[i]->values[k]->cnt) { /* if to allow testing of num_keys count of zero */
src[i]->tokens = (char**)malloc(src[i]->num_tokens * sizeof(char*)); src[i]->values[k]->keyvals = (orte_gpr_keyval_t**)malloc(
for (j=0; j < src[i]->num_tokens; j++) { src[i]->values[k]->cnt * sizeof(orte_gpr_keyval_t*));
src[i]->tokens[j] = strdup("test-token"); for (j=0; j < src[i]->values[k]->cnt; j++) {
} src[i]->values[k]->keyvals[j] = OBJ_NEW(orte_gpr_keyval_t);
} src[i]->values[k]->keyvals[j]->key = strdup("test-key");
}
/* test key counts of 0 to NUM_ELEMS */ }
src[i]->num_keys = i;
if (src[i]->num_keys) { /* if to allow testing of num_keys count of zero */
src[i]->keys = (char**)malloc(src[i]->num_keys * sizeof(char*));
for (j=0; j < src[i]->num_keys; j++) {
src[i]->keys[j] = strdup("test-key");
}
}
/* skip the pointers for cb_func and user_tag */ /* skip the pointers for cb_func and user_tag */
}
} }
/* source data set, now create buffer and pack source data */ /* source data set, now create buffer and pack source data */
@ -1528,29 +1542,48 @@ static bool test13(void)
for(j=0; j<NUM_ELEMS; j++) { for(j=0; j<NUM_ELEMS; j++) {
if ( if ((NULL == src[j]->name && NULL != dst[j]->name) ||
src[j]->addr_mode != dst[j]->addr_mode || (NULL != src[j]->name && NULL == dst[j]->name)
0 != strcmp(src[j]->segment, dst[j]->segment) || ) {
src[j]->num_tokens != dst[j]->num_tokens || test_comment ("test13: invalid results from unpack");
src[j]->num_keys != dst[j]->num_keys return(false);
}
if ((NULL != src[j]->name &&
0 != strcmp(src[j]->name, dst[j]->name)) ||
src[j]->id != dst[j]->id ||
src[j]->cnt != dst[j]->cnt
) { ) {
test_comment ("test13: invalid results from unpack"); test_comment ("test13: invalid results from unpack");
return(false); return(false);
} }
/* now compare each of the size/cnt depedant values */ /* now compare each of the size/cnt dependent values */
for (k=0; k<src[j]->num_tokens; k++) { for (k=0; k<src[j]->cnt; k++) {
if (0 != strcmp(src[j]->tokens[k], dst[j]->tokens[k])) { if (src[j]->values[k]->num_tokens != dst[j]->values[k]->num_tokens) {
test_comment ("test13: invalid results (tokens) from unpack"); test_comment ("test13: invalid results (value num_tokens) from unpack");
return(false); return(false);
} }
}
for (m=0; m < src[j]->values[k]->num_tokens; m++) {
if (0 != strcmp(src[j]->values[k]->tokens[m], dst[j]->values[k]->tokens[m])) {
test_comment ("test13: invalid results (tokens) from unpack");
return(false);
}
}
for (k=0; k< src[j]->num_keys; k++) { if (src[j]->values[k]->cnt != dst[j]->values[k]->cnt) {
if (0 != strcmp(src[j]->keys[k], dst[j]->keys[k])) { test_comment ("test13: invalid results (value cnt) from unpack");
test_comment ("test13: invalid results (keys) from unpack");
return(false); return(false);
} }
for (m=0; m < src[j]->values[k]->cnt; m++) {
if (0 != strcmp(src[j]->values[k]->keyvals[m]->key,
dst[j]->values[k]->keyvals[m]->key)) {
test_comment ("test13: invalid results (keys) from unpack");
return(false);
}
}
} }
} }
} }
@ -1576,9 +1609,7 @@ static bool test14(void)
for(i=0; i<NUM_ELEMS; i++) { for(i=0; i<NUM_ELEMS; i++) {
src[i] = OBJ_NEW(orte_gpr_notify_data_t); src[i] = OBJ_NEW(orte_gpr_notify_data_t);
src[i]->cb_num = i; src[i]->id = i;
src[i]->addr_mode = (orte_gpr_addr_mode_t) i;
src[i]->segment = strdup("test-segment-name");
/* test value counts of 0 to NUM_ELEMS-1 */ /* test value counts of 0 to NUM_ELEMS-1 */
src[i]->cnt = i; /* value count */ src[i]->cnt = i; /* value count */
@ -1651,9 +1682,7 @@ static bool test14(void)
for(j=0; j<NUM_ELEMS; j++) { for(j=0; j<NUM_ELEMS; j++) {
if ( if (
src[j]->cb_num != dst[j]->cb_num || src[j]->id != dst[j]->id ||
src[j]->addr_mode != dst[j]->addr_mode ||
0 != strcmp(src[j]->segment, dst[j]->segment) ||
src[j]->cnt != dst[j]->cnt src[j]->cnt != dst[j]->cnt
) { ) {
test_comment ("test14: invalid results from unpack"); test_comment ("test14: invalid results from unpack");

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

@ -16,4 +16,4 @@
include $(top_srcdir)/config/Makefile.options include $(top_srcdir)/config/Makefile.options
SUBDIRS = gpr ns oob ras rds rmaps schema SUBDIRS = ns oob ras rds rmaps schema

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

@ -28,8 +28,7 @@ check_PROGRAMS = \
gpr_threads \ gpr_threads \
gpr_triggers gpr_triggers
TESTS = \ TESTS =
$(check_PROGRAMS)
gpr_internal_fns_SOURCES = gpr_internal_fns.c gpr_internal_fns_SOURCES = gpr_internal_fns.c
gpr_internal_fns_LDADD = \ gpr_internal_fns_LDADD = \

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

@ -35,7 +35,6 @@
#include "mca/rmgr/base/base.h" #include "mca/rmgr/base/base.h"
#include "support.h" #include "support.h"
#include "components.h"
#include "class/orte_pointer_array.h" #include "class/orte_pointer_array.h"
#include "dps/dps.h" #include "dps/dps.h"
@ -57,17 +56,11 @@ static FILE *test_out=NULL;
static char *cmd_str="diff ./test_gpr_replica_out ./test_gpr_replica_out_std"; static char *cmd_str="diff ./test_gpr_replica_out ./test_gpr_replica_out_std";
/*
* Local functions
*/
static void find(const char *name, test_component_handle_t *handle,
test_component_fn_t *ptr);
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int rc; int rc;
size_t num_names, num_found; size_t num_names;
size_t i; size_t i;
char *tmp=NULL, *tmp2=NULL, *names[15], *keys[5]; char *tmp=NULL, *tmp2=NULL, *names[15], *keys[5];
orte_gpr_replica_segment_t *seg=NULL; orte_gpr_replica_segment_t *seg=NULL;
@ -75,25 +68,7 @@ int main(int argc, char **argv)
orte_gpr_replica_container_t *cptr=NULL; orte_gpr_replica_container_t *cptr=NULL;
orte_gpr_keyval_t *kptr=NULL; orte_gpr_keyval_t *kptr=NULL;
orte_gpr_replica_itagval_t **ivals=NULL, *iptr; orte_gpr_replica_itagval_t **ivals=NULL, *iptr;
bool allow, have;
int priority;
test_component_handle_t handle;
mca_gpr_base_component_t *gpr_component = NULL;
orte_gpr_base_module_t *gpr_module = NULL;
orte_gpr_replica_find_seg_fn_t find_seg_fn;
orte_gpr_replica_create_itag_fn_t create_itag_fn;
orte_gpr_replica_dict_lookup_fn_t dict_lookup_fn;
orte_gpr_replica_dict_reverse_lookup_fn_t dict_reverse_lookup_fn;
orte_gpr_replica_delete_itag_fn_t delete_itag_fn;
orte_gpr_replica_get_itag_list_fn_t get_itag_list_fn;
orte_gpr_replica_create_container_fn_t create_container_fn;
orte_gpr_replica_add_keyval_fn_t add_keyval_fn;
orte_gpr_replica_search_container_fn_t search_container_fn;
orte_gpr_replica_update_keyval_fn_t update_keyval_fn;
orte_gpr_replica_check_itag_list_fn_t check_itag_list_fn;
orte_gpr_replica_release_segment_fn_t release_segment_fn;
test_init("test_gpr_replica"); test_init("test_gpr_replica");
/* test_out = fopen( "test_gpr_replica_out", "w+" ); */ /* test_out = fopen( "test_gpr_replica_out", "w+" ); */
@ -190,59 +165,27 @@ int main(int argc, char **argv)
exit (1); exit (1);
} }
/* Open the gpr replica component and initialize a module */ /* startup the registry */
if (OMPI_SUCCESS != if (OMPI_SUCCESS == orte_gpr_base_open()) {
test_component_open("gpr", "replica", &handle, fprintf(test_out, "GPR started\n");
(mca_base_component_t**) &gpr_component) ||
NULL == gpr_component) {
fprintf(test_out, "Could not open replica\n");
exit(1);
}
gpr_module = gpr_component->gpr_init(&allow, &have, &priority);
if (NULL == gpr_module) {
fprintf(test_out, "replica component did not return a module\n");
exit(1);
}
if (ORTE_SUCCESS == orte_dps_open()) {
fprintf(test_out, "DPS started\n");
} else { } else {
fprintf(test_out, "DPS could not start\n"); fprintf(test_out, "GPR could not start\n");
exit (1); exit (1);
} }
/* Find a bunch of function pointers */ /* do a select on the registry components */
if (OMPI_SUCCESS == orte_gpr_base_select()) {
fprintf(test_out, "GPR selected\n");
} else {
fprintf(test_out, "GPR could not select\n");
exit (1);
}
fprintf(stderr, "finding relevant function pointers in component\n");
find("orte_gpr_replica_find_seg", &handle,
(test_component_fn_t*) &find_seg_fn);
find("orte_gpr_replica_create_itag", &handle,
(test_component_fn_t*) &create_itag_fn);
find("orte_gpr_replica_dict_lookup", &handle,
(test_component_fn_t*) &dict_lookup_fn);
find("orte_gpr_replica_dict_reverse_lookup", &handle,
(test_component_fn_t*) &dict_reverse_lookup_fn);
find("orte_gpr_replica_delete_itag", &handle,
(test_component_fn_t*) &delete_itag_fn);
find("orte_gpr_replica_get_itag_list", &handle,
(test_component_fn_t*) &get_itag_list_fn);
find("orte_gpr_replica_check_itag_list", &handle,
(test_component_fn_t*) &check_itag_list_fn);
find("orte_gpr_replica_create_container", &handle,
(test_component_fn_t*) &create_container_fn);
find("orte_gpr_replica_add_keyval", &handle,
(test_component_fn_t*) &add_keyval_fn);
find("orte_gpr_replica_search_container", &handle,
(test_component_fn_t*) &search_container_fn);
find("orte_gpr_replica_update_keyval", &handle,
(test_component_fn_t*) &update_keyval_fn);
find("orte_gpr_replica_release_segment", &handle,
(test_component_fn_t*) &release_segment_fn);
/* Now do the tests */ /* Now do the tests */
fprintf(stderr, "going to find seg\n"); fprintf(stderr, "going to find seg\n");
if (ORTE_SUCCESS != (rc = find_seg_fn(&seg, true, "test-segment"))) { if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_seg(&seg, true, "test-segment"))) {
fprintf(test_out, "gpr_test: find_seg failed with error code %s\n", fprintf(test_out, "gpr_test: find_seg failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: find_seg failed"); test_failure("gpr_test: find_seg failed");
@ -253,12 +196,12 @@ int main(int argc, char **argv)
fprintf(test_out, "gpr_test: find_seg passed\n"); fprintf(test_out, "gpr_test: find_seg passed\n");
} }
gpr_module->dump_all(0); orte_gpr.dump_all(0);
fprintf(stderr, "creating tags\n"); fprintf(stderr, "creating tags\n");
for (i=0; i<10; i++) { for (i=0; i<10; i++) {
asprintf(&tmp, "test-tag-%lu", (unsigned long) i); asprintf(&tmp, "test-tag-%lu", (unsigned long) i);
if (ORTE_SUCCESS != (rc = create_itag_fn(&itag[i], seg, tmp))) { if (ORTE_SUCCESS != (rc = orte_gpr_replica_create_itag(&itag[i], seg, tmp))) {
fprintf(test_out, "gpr_test: create_itag failed with error code %s\n", fprintf(test_out, "gpr_test: create_itag failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: create_itag failed"); test_failure("gpr_test: create_itag failed");
@ -274,7 +217,7 @@ int main(int argc, char **argv)
fprintf(stderr, "lookup tags\n"); fprintf(stderr, "lookup tags\n");
for (i=0; i<10; i++) { for (i=0; i<10; i++) {
asprintf(&tmp, "test-tag-%lu", (unsigned long) i); asprintf(&tmp, "test-tag-%lu", (unsigned long) i);
if (ORTE_SUCCESS != (rc = dict_lookup_fn(&itag2, seg, tmp)) || if (ORTE_SUCCESS != (rc = orte_gpr_replica_dict_lookup(&itag2, seg, tmp)) ||
itag2 != itag[i]) { itag2 != itag[i]) {
fprintf(test_out, "gpr_test: lookup failed with error code %s\n", fprintf(test_out, "gpr_test: lookup failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
@ -291,7 +234,7 @@ int main(int argc, char **argv)
fprintf(stderr, "reverse lookup tags\n"); fprintf(stderr, "reverse lookup tags\n");
for (i=0; i<10; i++) { for (i=0; i<10; i++) {
asprintf(&tmp2, "test-tag-%lu", (unsigned long) i); asprintf(&tmp2, "test-tag-%lu", (unsigned long) i);
if (ORTE_SUCCESS != (rc = dict_reverse_lookup_fn(&tmp, seg, itag[i])) || if (ORTE_SUCCESS != (rc = orte_gpr_replica_dict_reverse_lookup(&tmp, seg, itag[i])) ||
0 != strcmp(tmp2, tmp)) { 0 != strcmp(tmp2, tmp)) {
fprintf(test_out, "gpr_test: reverse lookup failed with error code %s\n", fprintf(test_out, "gpr_test: reverse lookup failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
@ -309,7 +252,7 @@ int main(int argc, char **argv)
fprintf(stderr, "delete tags\n"); fprintf(stderr, "delete tags\n");
for (i=0; i<10; i++) { for (i=0; i<10; i++) {
asprintf(&tmp, "test-tag-%lu", (unsigned long) i); asprintf(&tmp, "test-tag-%lu", (unsigned long) i);
if (ORTE_SUCCESS != (rc = delete_itag_fn(seg, tmp))) { if (ORTE_SUCCESS != (rc = orte_gpr_replica_delete_itag(seg, tmp))) {
fprintf(test_out, "gpr_test: delete tag failed with error code %s\n", fprintf(test_out, "gpr_test: delete tag failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: delete tag failed"); test_failure("gpr_test: delete tag failed");
@ -327,7 +270,7 @@ int main(int argc, char **argv)
} }
names[14] = NULL; names[14] = NULL;
num_names = 0; num_names = 0;
if (ORTE_SUCCESS != (rc = get_itag_list_fn(&itaglist, seg, if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_itag_list(&itaglist, seg,
names, &num_names))) { names, &num_names))) {
fprintf(test_out, "gpr_test: get itag list failed with error code %s\n", fprintf(test_out, "gpr_test: get itag list failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
@ -346,7 +289,7 @@ int main(int argc, char **argv)
} }
fprintf(stderr, "creating container\n"); fprintf(stderr, "creating container\n");
if (ORTE_SUCCESS != (rc = create_container_fn(&cptr, seg, if (ORTE_SUCCESS != (rc = orte_gpr_replica_create_container(&cptr, seg,
3, itaglist))) { 3, itaglist))) {
fprintf(test_out, "gpr_test: create_container failed with error code %s\n", fprintf(test_out, "gpr_test: create_container failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
@ -357,7 +300,7 @@ int main(int argc, char **argv)
fprintf(test_out, "gpr_test: create_container passed\n"); fprintf(test_out, "gpr_test: create_container passed\n");
} }
gpr_module->dump_all(0); orte_gpr.dump_all(0);
fprintf(test_out, "itags for container\n"); fprintf(test_out, "itags for container\n");
for (i=0; i < cptr->num_itags; i++) { for (i=0; i < cptr->num_itags; i++) {
@ -370,7 +313,7 @@ int main(int argc, char **argv)
kptr->key = strdup("stupid-value"); kptr->key = strdup("stupid-value");
kptr->type = ORTE_INT16; kptr->type = ORTE_INT16;
kptr->value.i16 = 21; kptr->value.i16 = 21;
if (ORTE_SUCCESS != (rc = add_keyval_fn(&iptr, seg, cptr, kptr))) { if (ORTE_SUCCESS != (rc = orte_gpr_replica_add_keyval(&iptr, seg, cptr, kptr))) {
fprintf(test_out, "gpr_test: add keyval failed with error code %s\n", fprintf(test_out, "gpr_test: add keyval failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: add keyval failed"); test_failure("gpr_test: add keyval failed");
@ -392,10 +335,10 @@ int main(int argc, char **argv)
kptr->key = strdup("stupid-value"); kptr->key = strdup("stupid-value");
kptr->type = ORTE_STRING; kptr->type = ORTE_STRING;
kptr->value.strptr = strdup("try-string-value"); kptr->value.strptr = strdup("try-string-value");
create_itag_fn(&itag2, seg, kptr->key); orte_gpr_replica_create_itag(&itag2, seg, kptr->key);
if (ORTE_SUCCESS != (rc = search_container_fn(&num_found, ORTE_GPR_REPLICA_OR, if (ORTE_SUCCESS != (rc = orte_gpr_replica_search_container(ORTE_GPR_REPLICA_OR,
&itag2, 1, cptr) || &itag2, 1, cptr) ||
0 >= num_found)) { 0 >= orte_gpr_replica_globals.num_srch_ival)) {
fprintf(test_out, "gpr_test: search container for single entry failed - returned %s for itag %lu\n", fprintf(test_out, "gpr_test: search container for single entry failed - returned %s for itag %lu\n",
ORTE_ERROR_NAME(rc), (unsigned long) itag2); ORTE_ERROR_NAME(rc), (unsigned long) itag2);
test_failure("gpr_test: search container for single entry failed"); test_failure("gpr_test: search container for single entry failed");
@ -411,7 +354,7 @@ int main(int argc, char **argv)
kptr->key = strdup("stupid-value"); kptr->key = strdup("stupid-value");
kptr->type = ORTE_STRING; kptr->type = ORTE_STRING;
kptr->value.strptr = strdup("try-string-value"); kptr->value.strptr = strdup("try-string-value");
if (ORTE_SUCCESS != (rc = update_keyval_fn(seg, cptr, kptr))) { if (ORTE_SUCCESS != (rc = orte_gpr_replica_update_keyval(seg, cptr, kptr))) {
fprintf(test_out, "gpr_test: update single keyval failed with error code %s\n", fprintf(test_out, "gpr_test: update single keyval failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: update single keyval failed"); test_failure("gpr_test: update single keyval failed");
@ -443,7 +386,7 @@ int main(int argc, char **argv)
kptr->key = strdup("stupid-value"); kptr->key = strdup("stupid-value");
kptr->type = ORTE_INT16; kptr->type = ORTE_INT16;
kptr->value.i16 = i * 100; kptr->value.i16 = i * 100;
if (ORTE_SUCCESS != (rc = add_keyval_fn(&iptr, seg, cptr, kptr))) { if (ORTE_SUCCESS != (rc = orte_gpr_replica_add_keyval(&iptr, seg, cptr, kptr))) {
fprintf(test_out, "gpr_test: add keyval failed with error code %s\n", fprintf(test_out, "gpr_test: add keyval failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: add keyval failed"); test_failure("gpr_test: add keyval failed");
@ -455,26 +398,20 @@ int main(int argc, char **argv)
OBJ_RELEASE(kptr); OBJ_RELEASE(kptr);
} }
fprintf(stderr, "update multiple keyvals in a container\n"); orte_gpr.dump_all(0);
if(ORTE_SUCCESS != find_seg_fn(&seg, false, "test-segment")) {
fprintf(test_out, "Failure in orte_gpr_replica_find_seg\n");
return -1;
}
gpr_module->dump_all(0);
kptr = OBJ_NEW(orte_gpr_keyval_t); kptr = OBJ_NEW(orte_gpr_keyval_t);
kptr->key = strdup("stupid-value"); kptr->key = strdup("stupid-value");
kptr->type = ORTE_INT32; kptr->type = ORTE_INT32;
kptr->value.i32 = 123456; kptr->value.i32 = 123456;
if (ORTE_SUCCESS != (rc = create_itag_fn(&itag2, seg, kptr->key))) { if (ORTE_SUCCESS != (rc = orte_gpr_replica_create_itag(&itag2, seg, kptr->key))) {
fprintf(test_out, "gpr_internal_fns: update multiple keyvals - failed to get itag with error %s\n", fprintf(test_out, "gpr_internal_fns: update multiple keyvals - failed to get itag with error %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: update multiple keyvals failed"); test_failure("gpr_test: update multiple keyvals failed");
test_finalize(); test_finalize();
return rc; return rc;
} }
if (ORTE_SUCCESS != (rc = search_container_fn(&num_found, ORTE_GPR_REPLICA_OR, if (ORTE_SUCCESS != (rc = orte_gpr_replica_search_container(ORTE_GPR_REPLICA_OR,
&itag2, 1, cptr))) { &itag2, 1, cptr))) {
fprintf(test_out, "gpr_internal_fns: update multiple keyvals - failed to find itag with error %s\n", fprintf(test_out, "gpr_internal_fns: update multiple keyvals - failed to find itag with error %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
@ -482,7 +419,7 @@ int main(int argc, char **argv)
test_finalize(); test_finalize();
return rc; return rc;
} }
if (ORTE_SUCCESS != (rc = update_keyval_fn(seg, cptr, kptr))) { if (ORTE_SUCCESS != (rc = orte_gpr_replica_update_keyval(seg, cptr, kptr))) {
fprintf(test_out, "gpr_test: update multiple keyvals failed with error code %s\n", fprintf(test_out, "gpr_test: update multiple keyvals failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: update multiple keyvals failed"); test_failure("gpr_test: update multiple keyvals failed");
@ -493,47 +430,50 @@ int main(int argc, char **argv)
} }
OBJ_RELEASE(kptr); OBJ_RELEASE(kptr);
gpr_module->dump_all(0); orte_gpr.dump_all(0);
fprintf(stderr, "check itag list\n"); fprintf(stderr, "check itag list\n");
if (check_itag_list_fn(ORTE_GPR_REPLICA_XAND, 0, NULL, 15, itaglist)) { if (orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_XAND, 0, NULL, 15, itaglist)) {
fprintf(test_out, "check_itag_list: trivial NULL case passed\n"); fprintf(test_out, "check_itag_list: trivial NULL case passed\n");
} else { } else {
fprintf(test_out, "check_itag_list: trivial NULL case failed\n"); fprintf(test_out, "check_itag_list: trivial NULL case failed\n");
} }
if (!check_itag_list_fn(ORTE_GPR_REPLICA_XAND, 5, itaglist, 15, itaglist)) { if (!orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_XAND, 5, itaglist, 15, itaglist)) {
fprintf(test_out, "check_itag_list: trivial mismatched xand case passed\n"); fprintf(test_out, "check_itag_list: trivial mismatched xand case passed\n");
} else { } else {
fprintf(test_out, "check_itag_list: trivial mismatched xand case failed\n"); fprintf(test_out, "check_itag_list: trivial mismatched xand case failed\n");
} }
if (!check_itag_list_fn(ORTE_GPR_REPLICA_AND, 15, itaglist, 5, itaglist)) { if (!orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_AND, 15, itaglist, 5, itaglist)) {
fprintf(test_out, "check_itag_list: trivial mismatched and case passed\n"); fprintf(test_out, "check_itag_list: trivial mismatched and case passed\n");
} else { } else {
fprintf(test_out, "check_itag_list: trivial mismatched and case failed\n"); fprintf(test_out, "check_itag_list: trivial mismatched and case failed\n");
} }
if (check_itag_list_fn(ORTE_GPR_REPLICA_XAND, 10, itaglist, 10, itaglist)) { if (orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_XAND, 10, itaglist, 10, itaglist)) {
fprintf(test_out, "check_itag_list: non-trivial xand case passed\n"); fprintf(test_out, "check_itag_list: non-trivial xand case passed\n");
} else { } else {
fprintf(test_out, "check_itag_list: non-trivial xand case failed\n"); fprintf(test_out, "check_itag_list: non-trivial xand case failed\n");
} }
if (check_itag_list_fn(ORTE_GPR_REPLICA_AND, 5, itaglist, 10, itaglist)) { if (orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_AND, 5, itaglist, 10, itaglist)) {
fprintf(test_out, "check_itag_list: non-trivial and case passed\n"); fprintf(test_out, "check_itag_list: non-trivial and case passed\n");
} else { } else {
fprintf(test_out, "check_itag_list: non-trivial and case failed\n"); fprintf(test_out, "check_itag_list: non-trivial and case failed\n");
} }
if (check_itag_list_fn(ORTE_GPR_REPLICA_OR, 5, itaglist, 10, itaglist)) { if (orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_OR, 5, itaglist, 10, itaglist)) {
fprintf(test_out, "check_itag_list: non-trivial or case passed\n"); fprintf(test_out, "check_itag_list: non-trivial or case passed\n");
} else { } else {
fprintf(test_out, "check_itag_list: non-trivial or case failed\n"); fprintf(test_out, "check_itag_list: non-trivial or case failed\n");
} }
if (check_itag_list_fn(ORTE_GPR_REPLICA_XOR, 10, itaglist, 5, itaglist)) { if (orte_gpr_replica_check_itag_list(ORTE_GPR_REPLICA_XOR, 10, itaglist, 5, itaglist)) {
fprintf(test_out, "check_itag_list: non-trivial or case passed\n"); fprintf(test_out, "check_itag_list: non-trivial or case passed\n");
} else { } else {
fprintf(test_out, "check_itag_list: non-trivial or case failed\n"); fprintf(test_out, "check_itag_list: non-trivial or case failed\n");
} }
fprintf(stderr, "\ncheck events prior to releasing segment to clear action records\n");
orte_gpr_replica_check_events();
fprintf(stderr, "\nreleasing segment\n"); fprintf(stderr, "\nreleasing segment\n");
if (ORTE_SUCCESS != (rc = release_segment_fn(&seg)) || if (ORTE_SUCCESS != (rc = orte_gpr_replica_release_segment(&seg)) ||
NULL != seg) { NULL != seg) {
fprintf(test_out, "gpr_test: release segment failed with error code %s\n", fprintf(test_out, "gpr_test: release segment failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
@ -554,10 +494,8 @@ int main(int argc, char **argv)
free(itaglist); free(itaglist);
/* finalize the gpr component */ /* finalize the gpr component */
if (NULL != gpr_component->gpr_finalize) { orte_gpr_base_close();
gpr_component->gpr_finalize();
}
test_component_close(&handle);
orte_dps_close(); orte_dps_close();
orte_sys_info_finalize(); orte_sys_info_finalize();
@ -581,17 +519,3 @@ int main(int argc, char **argv)
return 0; return 0;
} }
static void find(const char *name, test_component_handle_t *handle,
test_component_fn_t *ptr)
{
test_component_sym_t sym;
if (OMPI_SUCCESS !=
test_component_find_symbol(name, handle, &sym)) {
fprintf(test_out, "Unable to find symbol: %s\n", name);
exit(1);
}
fprintf(test_out, "Found symbol: %s\n", name);
*ptr = sym.tcs_function;
}

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

@ -35,7 +35,6 @@
#include "mca/rmgr/base/base.h" #include "mca/rmgr/base/base.h"
#include "support.h" #include "support.h"
#include "components.h"
#include "class/orte_pointer_array.h" #include "class/orte_pointer_array.h"
#include "dps/dps.h" #include "dps/dps.h"
@ -59,12 +58,7 @@ int main(int argc, char **argv)
size_t i, cnt; size_t i, cnt;
char *names[15], *keys[5]; char *names[15], *keys[5];
orte_gpr_value_t **values, *val; orte_gpr_value_t **values, *val;
test_component_handle_t handle;
mca_gpr_base_component_t *gpr_component = NULL;
orte_gpr_base_module_t *gpr_module = NULL;
bool allow, have;
int priority;
test_init("test_gpr_replica"); test_init("test_gpr_replica");
/* test_out = fopen( "test_gpr_replica_out", "w+" ); */ /* test_out = fopen( "test_gpr_replica_out", "w+" ); */
@ -156,24 +150,19 @@ int main(int argc, char **argv)
exit (1); exit (1);
} }
/* Open the gpr replica component and initialize a module */ /* startup the registry */
if (OMPI_SUCCESS != if (OMPI_SUCCESS == orte_gpr_base_open()) {
test_component_open("gpr", "replica", &handle, fprintf(test_out, "GPR started\n");
(mca_base_component_t**) &gpr_component) || } else {
NULL == gpr_component) { fprintf(test_out, "GPR could not start\n");
fprintf(test_out, "Could not open replica\n"); exit (1);
exit(1);
}
gpr_module = gpr_component->gpr_init(&allow, &have, &priority);
if (NULL == gpr_module) {
fprintf(test_out, "replica component did not return a module\n");
exit(1);
} }
if (ORTE_SUCCESS == orte_dps_open()) { /* do a select on the registry components */
fprintf(test_out, "DPS started\n"); if (OMPI_SUCCESS == orte_gpr_base_select()) {
fprintf(test_out, "GPR selected\n");
} else { } else {
fprintf(test_out, "DPS could not start\n"); fprintf(test_out, "GPR could not select\n");
exit (1); exit (1);
} }
@ -195,7 +184,7 @@ int main(int argc, char **argv)
(val->keyvals[i])->type = ORTE_UINT32; (val->keyvals[i])->type = ORTE_UINT32;
(val->keyvals[i])->value.ui32 = (uint32_t)i; (val->keyvals[i])->value.ui32 = (uint32_t)i;
} }
if (ORTE_SUCCESS != (rc = gpr_module->put(1, &val))) { if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(test_out, "gpr_test: put 1 value/multiple keyval failed with error code %s\n", fprintf(test_out, "gpr_test: put 1 value/multiple keyval failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: put 1 value/multiple keyval failed"); test_failure("gpr_test: put 1 value/multiple keyval failed");
@ -214,7 +203,7 @@ int main(int argc, char **argv)
keys[2] = strdup("stupid-test-5"); keys[2] = strdup("stupid-test-5");
keys[3] = strdup("stupid-test-8"); keys[3] = strdup("stupid-test-8");
keys[4] = NULL; keys[4] = NULL;
if (ORTE_SUCCESS != (rc = gpr_module->get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR, if (ORTE_SUCCESS != (rc = orte_gpr.get(ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
"test-put-segment", "test-put-segment",
names, keys, names, keys,
&cnt, &values))) { &cnt, &values))) {
@ -252,7 +241,7 @@ int main(int argc, char **argv)
(val->keyvals[0])->value.strptr = strdup("try-string-value"); (val->keyvals[0])->value.strptr = strdup("try-string-value");
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
fprintf(stderr, "\tputting copy %lu\n", (unsigned long) i); fprintf(stderr, "\tputting copy %lu\n", (unsigned long) i);
if (ORTE_SUCCESS != (rc = gpr_module->put(1, &val))) { if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &val))) {
fprintf(test_out, "gpr_test: put multiple copies of one keyval in a container failed with error code %s\n", fprintf(test_out, "gpr_test: put multiple copies of one keyval in a container failed with error code %s\n",
ORTE_ERROR_NAME(rc)); ORTE_ERROR_NAME(rc));
test_failure("gpr_test: put multiple copies of one keyval in a container failed"); test_failure("gpr_test: put multiple copies of one keyval in a container failed");
@ -265,7 +254,7 @@ int main(int argc, char **argv)
fprintf(stderr, "generate a trigger event\n"); fprintf(stderr, "generate a trigger event\n");
fprintf(stderr, "now finalize and see if all memory cleared\n"); fprintf(stderr, "now finalize and see if all memory cleared\n");
test_component_close(&handle); orte_gpr_base_close();
orte_dps_close(); orte_dps_close();
orte_sys_info_finalize(); orte_sys_info_finalize();
orte_proc_info_finalize(); orte_proc_info_finalize();

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

@ -177,27 +177,23 @@ int main(int argc, char **argv)
exit (1); exit (1);
} }
/* Open the gpr replica component and initialize a module */ /* startup the registry */
if (OMPI_SUCCESS != if (OMPI_SUCCESS == orte_gpr_base_open()) {
test_component_open("gpr", "replica", &handle, fprintf(test_out, "GPR started\n");
(mca_base_component_t**) &gpr_component) ||
NULL == gpr_component) {
fprintf(test_out, "Could not open replica\n");
exit(1);
}
gpr_module = gpr_component->gpr_init(&allow, &have, &priority);
if (NULL == gpr_module) {
fprintf(test_out, "replica component did not return a module\n");
exit(1);
}
if (ORTE_SUCCESS == orte_dps_open()) {
fprintf(test_out, "DPS started\n");
} else { } else {
fprintf(test_out, "DPS could not start\n"); fprintf(test_out, "GPR could not start\n");
exit (1); exit (1);
} }
/* do a select on the registry components */
if (OMPI_SUCCESS == orte_gpr_base_select()) {
fprintf(test_out, "GPR selected\n");
} else {
fprintf(test_out, "GPR could not select\n");
exit (1);
}
if (ORTE_SUCCESS == orte_errmgr_base_open()) { if (ORTE_SUCCESS == orte_errmgr_base_open()) {
fprintf(test_out, "error mgr started\n"); fprintf(test_out, "error mgr started\n");
} else { } else {
@ -205,22 +201,22 @@ int main(int argc, char **argv)
exit (1); exit (1);
} }
// /* test triggers that compare two counters to each other */ /* test triggers that compare two counters to each other */
// if (ORTE_SUCCESS == test1()) { if (ORTE_SUCCESS == test1()) {
// fprintf(test_out, "triggers: compare two counters successful\n"); fprintf(test_out, "triggers: compare two counters successful\n");
// } else { } else {
// fprintf(test_out, "triggers: compare two counters failed\n"); fprintf(test_out, "triggers: compare two counters failed\n");
// rc = 1; rc = 1;
// } }
//
// /* test triggers that fire at a level */ /* test triggers that fire at a level */
// if (ORTE_SUCCESS == test2()) { if (ORTE_SUCCESS == test2()) {
// fprintf(test_out, "triggers: trigger at level successful\n"); fprintf(test_out, "triggers: trigger at level successful\n");
// } else { } else {
// fprintf(test_out, "triggers: trigger at level failed\n"); fprintf(test_out, "triggers: trigger at level failed\n");
// rc = 1; rc = 1;
// } }
//
/* test notification on value added */ /* test notification on value added */
if (ORTE_SUCCESS == test3()) { if (ORTE_SUCCESS == test3()) {
fprintf(test_out, "triggers: notify upon value added successful\n"); fprintf(test_out, "triggers: notify upon value added successful\n");