Skip to content

Commit

Permalink
Implement the notification changes required to support the cross-libr…
Browse files Browse the repository at this point in the history
…ary integration

Refs pmix/RFCs#17
Refs open-mpi/ompi#3448

Signed-off-by: Ralph Castain <rhc@open-mpi.org>
  • Loading branch information
Ralph Castain committed May 5, 2017
1 parent 71ed965 commit b601d0a
Show file tree
Hide file tree
Showing 10 changed files with 372 additions and 78 deletions.
5 changes: 5 additions & 0 deletions include/pmix_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ typedef uint32_t pmix_rank_t;
#define PMIX_GRPID "pmix.egid" // (uint32_t) effective group id
#define PMIX_DSTPATH "pmix.dstpath" // (char*) path to dstore files
#define PMIX_VERSION_INFO "pmix.version" // (char*) PMIx version of contactor
#define PMIX_PROGRAMMING_MODEL "pmix.pgm.model" // (char*) programming model being initialized (e.g., "MPI" or "OpenMP")
#define PMIX_MODEL_LIBRARY_NAME "pmix.mdl.name" // (char*) programming model implementation ID (e.g., "OpenMPI" or "MPICH")
#define PMIX_MODEL_LIBRARY_VERSION "pmix.mld.vrs" // (char*) programming model version string (e.g., "2.1.1")
#define PMIX_THREADING_MODEL "pmix.threads" // (char*) threading model used (e.g., "pthreads")


/* attributes for the USOCK rendezvous socket */
Expand Down Expand Up @@ -531,6 +535,7 @@ typedef int pmix_status_t;
#define PMIX_ERR_EVENT_REGISTRATION (PMIX_ERR_OP_BASE - 14)
#define PMIX_ERR_JOB_TERMINATED (PMIX_ERR_OP_BASE - 15)
#define PMIX_ERR_UPDATE_ENDPOINTS (PMIX_ERR_OP_BASE - 16)
#define PMIX_MODEL_DECLARED (PMIX_ERR_OP_BASE - 17)

/* define a starting point for system error constants so
* we avoid renumbering when making additions */
Expand Down
84 changes: 84 additions & 0 deletions src/client/pmix_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,79 @@ static void evhandler_reg_callbk(pmix_status_t status,
*active = status;
}

typedef struct {
pmix_info_t *info;
size_t ninfo;
} mydata_t;

static void release_info(pmix_status_t status, void *cbdata)
{
mydata_t *cd = (mydata_t*)cbdata;
PMIX_INFO_FREE(cd->info, cd->ninfo);
free(cd);
}

static void _check_for_notify(pmix_info_t info[], size_t ninfo)
{
mydata_t *cd;
size_t n, m=0;
pmix_info_t *model=NULL, *library=NULL, *vers=NULL, *tmod=NULL;

for (n=0; n < ninfo; n++) {
if (0 == strncmp(info[n].key, PMIX_PROGRAMMING_MODEL, PMIX_MAX_KEYLEN)) {
/* we need to generate an event indicating that
* a programming model has been declared */
model = &info[n];
++m;
} else if (0 == strncmp(info[n].key, PMIX_MODEL_LIBRARY_NAME, PMIX_MAX_KEYLEN)) {
library = &info[n];
++m;
} else if (0 == strncmp(info[n].key, PMIX_MODEL_LIBRARY_VERSION, PMIX_MAX_KEYLEN)) {
vers = &info[n];
++m;
} else if (0 == strncmp(info[n].key, PMIX_THREADING_MODEL, PMIX_MAX_KEYLEN)) {
tmod = &info[n];
++m;
}
}
if (0 < m) {
/* notify anyone listening that a model has been declared */
cd = (mydata_t*)malloc(sizeof(mydata_t));
if (NULL == cd) {
/* nothing we can do */
return;
}
PMIX_INFO_CREATE(cd->info, m+1);
if (NULL == cd->info) {
free(cd);
return;
}
cd->ninfo = m+1;
n = 0;
if (NULL != model) {
PMIX_INFO_XFER(&cd->info[n], model);
++n;
}
if (NULL != library) {
PMIX_INFO_XFER(&cd->info[n], library);
++n;
}
if (NULL != vers) {
PMIX_INFO_XFER(&cd->info[n], vers);
++n;
}
if (NULL != tmod) {
PMIX_INFO_XFER(&cd->info[n], tmod);
++n;
}
/* mark that it is not to go to any default handlers */
PMIX_INFO_LOAD(&cd->info[n], PMIX_EVENT_NON_DEFAULT, NULL, PMIX_BOOL);
PMIx_Notify_event(PMIX_MODEL_DECLARED,
&pmix_globals.myid, PMIX_RANGE_PROC_LOCAL,
cd->info, cd->ninfo, release_info, (void*)cd);
}
}

PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc,
pmix_info_t info[], size_t ninfo)
{
Expand Down Expand Up @@ -267,6 +340,12 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc,
(void)strncpy(proc->nspace, pmix_globals.myid.nspace, PMIX_MAX_NSLEN);
proc->rank = pmix_globals.myid.rank;
}
/* we also need to check the info keys to see if something need
* be done with them - e.g., to notify another library that we
* also have called init */
if (NULL != info) {
_check_for_notify(info, ninfo);
}
++pmix_globals.init_cntr;
pmix_mutex_unlock(&pmix_client_bootstrap_mutex);
return PMIX_SUCCESS;
Expand Down Expand Up @@ -396,6 +475,11 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc,
}
PMIX_INFO_DESTRUCT(&ginfo);

/* check to see if we need to notify anyone */
if (NULL != info) {
_check_for_notify(info, ninfo);
}

pmix_mutex_unlock(&pmix_client_bootstrap_mutex);

return PMIX_SUCCESS;
Expand Down
5 changes: 4 additions & 1 deletion src/event/pmix_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ pmix_status_t pmix_server_notify_client_of_event(pmix_status_t status,
pmix_event_chain_t *_ch; \
_ch = PMIX_NEW(pmix_event_chain_t); \
_ch->status = (e); \
_ch->ninfo = 1; \
_ch->ninfo = 2; \
_ch->final_cbfunc = (f); \
_ch->final_cbdata = _ch; \
PMIX_INFO_CREATE(_ch->info, _ch->ninfo); \
PMIX_INFO_LOAD(&_ch->info[0], \
PMIX_EVENT_HDLR_NAME, \
NULL, PMIX_STRING); \
PMIX_INFO_LOAD(&_ch->info[1], \
PMIX_EVENT_RETURN_OBJECT, \
NULL, PMIX_POINTER); \
pmix_invoke_local_event_hdlr(_ch); \
Expand Down
Loading

0 comments on commit b601d0a

Please sign in to comment.