Skip to content

Commit 8451015

Browse files
committed
Update with new log2 and tool_connected2 upcalls
Standard has been updated to allow the log and tool_connected upcalls to return status codes. Update here to support them Signed-off-by: Ralph Castain <[email protected]>
1 parent ac77387 commit 8451015

File tree

3 files changed

+157
-0
lines changed

3 files changed

+157
-0
lines changed

src/prted/pmix/pmix_server.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ static pmix_server_module_t pmix_server = {
114114
.notify_event = pmix_server_notify_event,
115115
.query = pmix_server_query_fn,
116116
.tool_connected = pmix_tool_connected_fn,
117+
#ifdef pmix_server_tool_connected2_fn
118+
.tool_connected2 = pmix_tool_connected2_fn,
119+
#endif
117120
.log = pmix_server_log_fn,
121+
#ifdef pmix_server_log2_fn
122+
.log2 = pmix_server_log2_fn,
123+
#endif
118124
.job_control = pmix_server_job_ctrl_fn,
119125
.iof_pull = pmix_server_iof_pull_fn,
120126
.push_stdin = pmix_server_stdin_fn,

src/prted/pmix/pmix_server_gen.c

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,33 @@ void pmix_tool_connected_fn(pmix_info_t *info, size_t ninfo,
928928
prte_event_active(&(cd->ev), PRTE_EV_WRITE, 1);
929929
}
930930

931+
#ifdef pmix_server_tool_connected2_fn
932+
pmix_status_t pmix_tool_connected2_fn(pmix_info_t *info, size_t ninfo,
933+
pmix_tool_connection_cbfunc_t cbfunc,
934+
void *cbdata)
935+
{
936+
pmix_server_req_t *cd;
937+
938+
pmix_output_verbose(2, prte_pmix_server_globals.output,
939+
"%s TOOL CONNECTION2 REQUEST RECVD",
940+
PRTE_NAME_PRINT(PRTE_PROC_MY_NAME));
941+
942+
/* need to threadshift this request */
943+
cd = PMIX_NEW(pmix_server_req_t);
944+
cd->toolcbfunc = cbfunc;
945+
cd->cbdata = cbdata;
946+
cd->target.rank = 0; // set default for tool
947+
cd->info = info;
948+
cd->ninfo = ninfo;
949+
950+
prte_event_set(prte_event_base, &(cd->ev), -1, PRTE_EV_WRITE, _toolconn, cd);
951+
PMIX_POST_OBJECT(cd);
952+
prte_event_active(&(cd->ev), PRTE_EV_WRITE, 1);
953+
954+
return PMIX_SUCCESS;
955+
}
956+
#endif
957+
931958
static void lgcbfn(int sd, short args, void *cbdata)
932959
{
933960
prte_pmix_server_op_caddy_t *cd = (prte_pmix_server_op_caddy_t *) cbdata;
@@ -1031,6 +1058,119 @@ void pmix_server_log_fn(const pmix_proc_t *client, const pmix_info_t data[], siz
10311058
PRTE_SERVER_PMIX_THREADSHIFT(PRTE_NAME_WILDCARD, NULL, rc, NULL, NULL, 0, lgcbfn, cbfunc, cbdata);
10321059
}
10331060

1061+
#ifdef pmix_server_log2_fn
1062+
pmix_status_t pmix_server_log2_fn(const pmix_proc_t *client, const pmix_info_t data[], size_t ndata,
1063+
const pmix_info_t directives[], size_t ndirs, pmix_op_cbfunc_t cbfunc,
1064+
void *cbdata)
1065+
{
1066+
size_t n, cnt, dcnt;
1067+
pmix_data_buffer_t *buf;
1068+
int rc = PRTE_SUCCESS;
1069+
pmix_data_buffer_t pbuf, dbuf;
1070+
pmix_byte_object_t pbo, dbo;
1071+
pmix_status_t ret;
1072+
1073+
pmix_output_verbose(2, prte_pmix_server_globals.output,
1074+
"%s logging2 info",
1075+
PRTE_NAME_PRINT(PRTE_PROC_MY_NAME));
1076+
1077+
PMIX_DATA_BUFFER_CONSTRUCT(&dbuf);
1078+
/* if we are the one that passed it down, then we don't pass it back */
1079+
dcnt = 0;
1080+
for (n = 0; n < ndirs; n++) {
1081+
if (PMIX_CHECK_KEY(&directives[n], "prte.log.noloop")) {
1082+
if (PMIX_INFO_TRUE(&directives[n])) {
1083+
rc = PMIX_SUCCESS;
1084+
goto done;
1085+
}
1086+
}
1087+
else {
1088+
ret = PMIx_Data_pack(NULL, &dbuf, (pmix_info_t *) &directives[n], 1, PMIX_INFO);
1089+
if (PMIX_SUCCESS != ret) {
1090+
PMIX_ERROR_LOG(ret);
1091+
return ret;
1092+
}
1093+
dcnt++;
1094+
}
1095+
}
1096+
1097+
PMIX_DATA_BUFFER_CONSTRUCT(&pbuf);
1098+
cnt = 0;
1099+
1100+
for (n = 0; n < ndata; n++) {
1101+
/* ship this to our HNP/MASTER for processing, even if that is us */
1102+
ret = PMIx_Data_pack(NULL, &pbuf, (pmix_info_t *) &data[n], 1, PMIX_INFO);
1103+
if (PMIX_SUCCESS != ret) {
1104+
PMIX_ERROR_LOG(ret);
1105+
PMIX_DATA_BUFFER_DESTRUCT(&pbuf);
1106+
return ret;
1107+
}
1108+
++cnt;
1109+
}
1110+
if (0 < cnt) {
1111+
PMIX_DATA_BUFFER_CREATE(buf);
1112+
/* pack the source of this log request */
1113+
rc = PMIx_Data_pack(NULL, buf, (void*)client, 1, PMIX_PROC);
1114+
if (PMIX_SUCCESS != rc) {
1115+
PMIX_ERROR_LOG(rc);
1116+
PMIX_DATA_BUFFER_RELEASE(buf);
1117+
PMIX_DATA_BUFFER_DESTRUCT(&pbuf);
1118+
return rc;
1119+
}
1120+
/* pack number of info provided */
1121+
rc = PMIx_Data_pack(NULL, buf, &cnt, 1, PMIX_SIZE);
1122+
if (PMIX_SUCCESS != rc) {
1123+
PMIX_ERROR_LOG(rc);
1124+
PMIX_DATA_BUFFER_RELEASE(buf);
1125+
PMIX_DATA_BUFFER_DESTRUCT(&pbuf);
1126+
return rc;
1127+
}
1128+
/* pack number of directives given */
1129+
rc = PMIx_Data_pack(NULL, buf, &dcnt, 1, PMIX_SIZE);
1130+
if (PMIX_SUCCESS != rc) {
1131+
PMIX_ERROR_LOG(rc);
1132+
PMIX_DATA_BUFFER_RELEASE(buf);
1133+
PMIX_DATA_BUFFER_DESTRUCT(&pbuf);
1134+
return rc;
1135+
}
1136+
/* bring over the packed info blob */
1137+
rc = PMIx_Data_unload(&pbuf, &pbo);
1138+
if (PMIX_SUCCESS != rc) {
1139+
PMIX_ERROR_LOG(rc);
1140+
PMIX_DATA_BUFFER_RELEASE(buf);
1141+
PMIX_DATA_BUFFER_DESTRUCT(&pbuf);
1142+
return rc;
1143+
}
1144+
rc = PMIx_Data_pack(NULL, buf, &pbo, 1, PMIX_BYTE_OBJECT);
1145+
PMIX_BYTE_OBJECT_DESTRUCT(&pbo);
1146+
/* pack the directives blob */
1147+
rc = PMIx_Data_unload(&dbuf, &dbo);
1148+
if (PMIX_SUCCESS != rc) {
1149+
PMIX_ERROR_LOG(rc);
1150+
PMIX_DATA_BUFFER_RELEASE(buf);
1151+
return rc;
1152+
}
1153+
rc = PMIx_Data_pack(NULL, buf, &dbo, 1, PMIX_BYTE_OBJECT);
1154+
PMIX_BYTE_OBJECT_DESTRUCT(&dbo);
1155+
/* send the result to the HNP */
1156+
PRTE_RML_SEND(rc, PRTE_PROC_MY_HNP->rank, buf,
1157+
PRTE_RML_TAG_LOGGING);
1158+
if (PRTE_SUCCESS != rc) {
1159+
PRTE_ERROR_LOG(rc);
1160+
PMIX_DATA_BUFFER_RELEASE(buf);
1161+
return rc;
1162+
}
1163+
}
1164+
1165+
done:
1166+
/* we cannot directly execute the callback here
1167+
* as it would threadlock - so shift to somewhere
1168+
* safe */
1169+
PRTE_SERVER_PMIX_THREADSHIFT(PRTE_NAME_WILDCARD, NULL, rc, NULL, NULL, 0, lgcbfn, cbfunc, cbdata);
1170+
return PMIX_SUCCESS;
1171+
}
1172+
#endif
1173+
10341174
pmix_status_t pmix_server_job_ctrl_fn(const pmix_proc_t *requestor, const pmix_proc_t targets[],
10351175
size_t ntargets, const pmix_info_t directives[], size_t ndirs,
10361176
pmix_info_cbfunc_t cbfunc, void *cbdata)

src/prted/pmix/pmix_server_internal.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,21 @@ PRTE_EXPORT extern pmix_status_t pmix_server_query_fn(pmix_proc_t *proct, pmix_q
266266
PRTE_EXPORT extern void pmix_tool_connected_fn(pmix_info_t *info, size_t ninfo,
267267
pmix_tool_connection_cbfunc_t cbfunc, void *cbdata);
268268

269+
#ifdef pmix_server_tool_connected2_fn
270+
PRTE_EXPORT extern pmix_status_t pmix_tool_connected2_fn(pmix_info_t *info, size_t ninfo,
271+
pmix_tool_connection_cbfunc_t cbfunc, void *cbdata);
272+
#endif
273+
269274
PRTE_EXPORT extern void pmix_server_log_fn(const pmix_proc_t *client, const pmix_info_t data[],
270275
size_t ndata, const pmix_info_t directives[],
271276
size_t ndirs, pmix_op_cbfunc_t cbfunc, void *cbdata);
272277

278+
#ifdef pmix_server_log2_fn
279+
PRTE_EXPORT extern pmix_status_t pmix_server_log2_fn(const pmix_proc_t *client, const pmix_info_t data[],
280+
size_t ndata, const pmix_info_t directives[],
281+
size_t ndirs, pmix_op_cbfunc_t cbfunc, void *cbdata);
282+
#endif
283+
273284
PRTE_EXPORT extern pmix_status_t pmix_server_alloc_fn(const pmix_proc_t *client,
274285
pmix_alloc_directive_t directive,
275286
const pmix_info_t data[], size_t ndata,

0 commit comments

Comments
 (0)