Skip to content

Commit 6ea3c8a

Browse files
author
Ralph Castain
committed
Update the interlib example to show an alternative method for model declaration. Add a missing range value to the OPAL layer. Make it easier to see OMPI model callbacks
Signed-off-by: Ralph Castain <[email protected]>
1 parent 79aef93 commit 6ea3c8a

File tree

6 files changed

+67
-36
lines changed

6 files changed

+67
-36
lines changed

ompi/interlib/interlib.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,18 @@ static void model_callback(int status,
6262
{
6363
opal_value_t *val;
6464

65-
/* we can ignore our own callback as we obviously
66-
* know that we are MPI */
67-
if (NULL != info) {
68-
OPAL_LIST_FOREACH(val, info, opal_value_t) {
69-
if (OPAL_STRING == val->type) {
70-
#if 0
71-
opal_output(0, "OMPI Model Callback Key: %s Val %s", val->key, val->data.string);
72-
#else
73-
if (0 == strcmp(val->key, OPAL_PMIX_MODEL_LIBRARY_NAME) &&
74-
0 == strcmp(val->data.string, "OpenMPI")) {
65+
if (NULL != getenv("OMPI_SHOW_MODEL_CALLBACK")) {
66+
/* we can ignore our own callback as we obviously
67+
* know that we are MPI */
68+
if (NULL != info) {
69+
OPAL_LIST_FOREACH(val, info, opal_value_t) {
70+
if (0 == strcmp(val->key, OPAL_PMIX_PROGRAMMING_MODEL) &&
71+
0 == strcmp(val->data.string, "MPI")) {
7572
goto cback;
7673
}
77-
#endif
74+
if (OPAL_STRING == val->type) {
75+
opal_output(0, "OMPI Model Callback Key: %s Val %s", val->key, val->data.string);
76+
}
7877
}
7978
}
8079
}

opal/mca/pmix/pmix3x/pmix/src/common/pmix_strings.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ PMIX_EXPORT const char* PMIx_Data_range_string(pmix_data_range_t range)
139139
return "AVAIL TO ANYONE WITH AUTHORIZATION";
140140
case PMIX_RANGE_CUSTOM:
141141
return "AVAIL AS SPECIFIED IN DIRECTIVES";
142+
case PMIX_RANGE_PROC_LOCAL:
143+
return "AVAIL ON LOCAL PROC ONLY";
142144
default:
143145
return "UNKNOWN";
144146
}

opal/mca/pmix/pmix3x/pmix/src/event/pmix_event_notification.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ static pmix_status_t notify_server_of_event(pmix_status_t status,
117117
pmix_notify_caddy_t *cd, *rbout;
118118

119119
pmix_output_verbose(2, pmix_globals.debug_output,
120-
"client: notifying server %s:%d of status %s",
120+
"client: notifying server %s:%d of status %s for range %s",
121121
pmix_globals.myid.nspace, pmix_globals.myid.rank,
122-
PMIx_Error_string(status));
122+
PMIx_Error_string(status), PMIx_Data_range_string(range));
123123

124124
if (PMIX_RANGE_PROC_LOCAL != range) {
125125
/* create the msg object */

opal/mca/pmix/pmix3x/pmix3x.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ pmix_data_range_t pmix3x_convert_opalrange(opal_pmix_data_range_t range) {
578578
return PMIX_RANGE_GLOBAL;
579579
case OPAL_PMIX_RANGE_CUSTOM:
580580
return PMIX_RANGE_CUSTOM;
581+
case OPAL_PMIX_RANGE_PROC_LOCAL:
582+
return PMIX_RANGE_PROC_LOCAL;
581583
default:
582584
return PMIX_SCOPE_UNDEF;
583585
}

opal/mca/pmix/pmix_types.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,16 @@ typedef enum {
401401
} opal_pmix_scope_t;
402402

403403
/* define a range for data "published" by PMI */
404-
#define OPAL_PMIX_DATA_RANGE OPAL_UINT
405-
typedef enum {
406-
OPAL_PMIX_RANGE_UNDEF = 0,
407-
OPAL_PMIX_RANGE_RM, // data is intended for the host resource manager
408-
OPAL_PMIX_RANGE_LOCAL, // available on local node only
409-
OPAL_PMIX_RANGE_NAMESPACE, // data is available to procs in the same nspace only
410-
OPAL_PMIX_RANGE_SESSION, // data available to all procs in session
411-
OPAL_PMIX_RANGE_GLOBAL, // data available to all procs
412-
OPAL_PMIX_RANGE_CUSTOM // range is specified in a opal_value_t
413-
} opal_pmix_data_range_t;
404+
#define OPAL_PMIX_DATA_RANGE OPAL_UINT8
405+
typedef uint8_t opal_pmix_data_range_t;
406+
#define OPAL_PMIX_RANGE_UNDEF 0
407+
#define OPAL_PMIX_RANGE_RM 1 // data is intended for the host resource manager
408+
#define OPAL_PMIX_RANGE_LOCAL 2 // available on local node only
409+
#define OPAL_PMIX_RANGE_NAMESPACE 3 // data is available to procs in the same nspace only
410+
#define OPAL_PMIX_RANGE_SESSION 4 // data available to all procs in session
411+
#define OPAL_PMIX_RANGE_GLOBAL 5 // data available to all procs
412+
#define OPAL_PMIX_RANGE_CUSTOM 6 // range is specified in a pmix_info_t
413+
#define OPAL_PMIX_RANGE_PROC_LOCAL 7 // restrict range to the local proc
414414

415415
/* define a "persistence" policy for data published by clients */
416416
typedef enum {

orte/test/mpi/interlib.c

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,15 @@ static void model_callback(int status,
3535
opal_value_t *val;
3636

3737
/* we can ignore our own callback as we obviously
38-
* know that we are MPI */
38+
* know that we are OpenMP */
3939
if (NULL != info) {
4040
OPAL_LIST_FOREACH(val, info, opal_value_t) {
41+
if (0 == strcmp(val->key, OPAL_PMIX_PROGRAMMING_MODEL) &&
42+
0 == strcmp(val->data.string, "OpenMP")) {
43+
goto cback;
44+
}
4145
if (OPAL_STRING == val->type) {
42-
#if 1
4346
opal_output(0, "Thread Model Callback Key: %s Val %s", val->key, val->data.string);
44-
#else
45-
if (0 == strcmp(val->key, OPAL_PMIX_MODEL_LIBRARY_NAME) &&
46-
0 == strcmp(val->data.string, "OpenMPI")) {
47-
goto cback;
48-
}
49-
#endif
5047
}
5148
}
5249
}
@@ -62,12 +59,19 @@ static void model_callback(int status,
6259
OPAL_PMIX_WAKEUP_THREAD(&thread_complete);
6360
}
6461

62+
static void opcbfunc(int status, void *cbdata)
63+
{
64+
opal_pmix_lock_t *lock = (opal_pmix_lock_t*)cbdata;
65+
OPAL_PMIX_WAKEUP_THREAD(lock);
66+
}
67+
6568
static void *mylib(void *ptr)
6669
{
6770
opal_list_t info, directives;
6871
opal_value_t *kv;
6972
int ret;
7073
opal_pmix_lock_t lock;
74+
bool init = false;
7175

7276
OPAL_PMIX_CONSTRUCT_LOCK(&thread_complete);
7377

@@ -94,9 +98,31 @@ static void *mylib(void *ptr)
9498
kv->data.string = strdup("PTHREAD");
9599
opal_list_append(&info, &kv->super);
96100

97-
/* call pmix to initialize these values */
98-
ret = opal_pmix.init(&info);
99-
OPAL_LIST_DESTRUCT(&info);
101+
/* see if pmix is already initialized */
102+
if (opal_pmix.initialized()) {
103+
/* mark that this isn't to go to any default event handler - pmix_init
104+
* takes care of that for us, but we have to explicitly do it here */
105+
kv = OBJ_NEW(opal_value_t);
106+
kv->key = strdup(OPAL_PMIX_EVENT_NON_DEFAULT);
107+
kv->type = OPAL_BOOL;
108+
kv->data.flag = true;
109+
opal_list_append(&info, &kv->super);
110+
/* it is, so let's just use the event notification
111+
* API to let everyone know we are here */
112+
OPAL_PMIX_CONSTRUCT_LOCK(&lock);
113+
ret = opal_pmix.notify_event(OPAL_ERR_MODEL_DECLARED,
114+
&orte_process_info.my_name,
115+
OPAL_PMIX_RANGE_PROC_LOCAL, &info,
116+
opcbfunc, &lock);
117+
OPAL_PMIX_WAIT_THREAD(&lock);
118+
OPAL_PMIX_DESTRUCT_LOCK(&lock);
119+
OPAL_LIST_DESTRUCT(&info);
120+
} else {
121+
/* call pmix to initialize these values */
122+
ret = opal_pmix.init(&info);
123+
OPAL_LIST_DESTRUCT(&info);
124+
init = true;
125+
}
100126

101127
/* register to receive model callbacks */
102128

@@ -128,8 +154,10 @@ static void *mylib(void *ptr)
128154
/* wait for the model callback */
129155
OPAL_PMIX_WAIT_THREAD(&thread_complete);
130156

131-
/* finalize */
132-
opal_pmix.finalize();
157+
if (init) {
158+
/* need to finalize to maintain refcount */
159+
opal_pmix.finalize();
160+
}
133161

134162
/* done */
135163
return NULL;

0 commit comments

Comments
 (0)