Skip to content

Commit 98aee54

Browse files
author
Ralph Castain
authored
Merge pull request #4278 from rhc54/topic/pup
Sync to PMIx master to pickup a little bug fix
2 parents 92e4ecb + 57c14cb commit 98aee54

File tree

10 files changed

+345
-80
lines changed

10 files changed

+345
-80
lines changed

opal/mca/pmix/pmix2x/pmix/VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ greek=
3030
# command, or with the date (if "git describe" fails) in the form of
3131
# "date<date>".
3232

33-
repo_rev=git9cf5d19
33+
repo_rev=git9d9df02
3434

3535
# If tarball_version is not empty, it is used as the version string in
3636
# the tarball filename, regardless of all other versions listed in
@@ -44,7 +44,7 @@ tarball_version=
4444

4545
# The date when this release was created
4646

47-
date="Sep 25, 2017"
47+
date="Sep 27, 2017"
4848

4949
# The shared library version of each of PMIx's public libraries.
5050
# These versions are maintained in accordance with the "Library

opal/mca/pmix/pmix2x/pmix/examples/Makefile.am

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_builddir)/src/include -I$(top_builddir)/include -I$(top_builddir)/include/pmix
2323

24-
noinst_PROGRAMS = client dmodex dynamic fault pub tool debugger debuggerd alloc jctrl
24+
noinst_PROGRAMS = client client2 dmodex dynamic fault pub tool debugger debuggerd alloc jctrl
2525
if !WANT_HIDDEN
2626
# these examples use internal symbols
2727
# use --disable-visibility
@@ -32,6 +32,10 @@ client_SOURCES = client.c
3232
client_LDFLAGS = $(PMIX_PKG_CONFIG_LDFLAGS)
3333
client_LDADD = $(top_builddir)/src/libpmix.la
3434

35+
client2_SOURCES = client2.c
36+
client2_LDFLAGS = $(PMIX_PKG_CONFIG_LDFLAGS)
37+
client2_LDADD = $(top_builddir)/src/libpmix.la
38+
3539
debugger_SOURCES = debugger.c
3640
debugger_LDFLAGS = $(PMIX_PKG_CONFIG_LDFLAGS)
3741
debugger_LDADD = $(top_builddir)/src/libpmix.la
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
/*
2+
* Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
3+
* University Research and Technology
4+
* Corporation. All rights reserved.
5+
* Copyright (c) 2004-2011 The University of Tennessee and The University
6+
* of Tennessee Research Foundation. All rights
7+
* reserved.
8+
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9+
* University of Stuttgart. All rights reserved.
10+
* Copyright (c) 2004-2005 The Regents of the University of California.
11+
* All rights reserved.
12+
* Copyright (c) 2006-2013 Los Alamos National Security, LLC.
13+
* All rights reserved.
14+
* Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved.
15+
* Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
16+
* Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
17+
* Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved.
18+
* $COPYRIGHT$
19+
*
20+
* Additional copyrights may follow
21+
*
22+
* $HEADER$
23+
*
24+
*/
25+
26+
#define _GNU_SOURCE
27+
#include <stdbool.h>
28+
#include <stdio.h>
29+
#include <stdlib.h>
30+
#include <unistd.h>
31+
#include <time.h>
32+
33+
#include <pmix.h>
34+
35+
static pmix_proc_t myproc;
36+
37+
/* this is the event notification function we pass down below
38+
* when registering for general events - i.e.,, the default
39+
* handler. We don't technically need to register one, but it
40+
* is usually good practice to catch any events that occur */
41+
static void notification_fn(size_t evhdlr_registration_id,
42+
pmix_status_t status,
43+
const pmix_proc_t *source,
44+
pmix_info_t info[], size_t ninfo,
45+
pmix_info_t results[], size_t nresults,
46+
pmix_event_notification_cbfunc_fn_t cbfunc,
47+
void *cbdata)
48+
{
49+
if (NULL != cbfunc) {
50+
cbfunc(PMIX_EVENT_ACTION_COMPLETE, NULL, 0, NULL, NULL, cbdata);
51+
}
52+
}
53+
54+
/* event handler registration is done asynchronously because it
55+
* may involve the PMIx server registering with the host RM for
56+
* external events. So we provide a callback function that returns
57+
* the status of the request (success or an error), plus a numerical index
58+
* to the registered event. The index is used later on to deregister
59+
* an event handler - if we don't explicitly deregister it, then the
60+
* PMIx server will do so when it see us exit */
61+
static void evhandler_reg_callbk(pmix_status_t status,
62+
size_t evhandler_ref,
63+
void *cbdata)
64+
{
65+
volatile int *active = (volatile int*)cbdata;
66+
67+
if (PMIX_SUCCESS != status) {
68+
fprintf(stderr, "Client %s:%d EVENT HANDLER REGISTRATION FAILED WITH STATUS %d, ref=%lu\n",
69+
myproc.nspace, myproc.rank, status, (unsigned long)evhandler_ref);
70+
}
71+
*active = status;
72+
}
73+
74+
int main(int argc, char **argv)
75+
{
76+
int rc;
77+
pmix_value_t value;
78+
pmix_value_t *val, *vptr;
79+
pmix_proc_t proc;
80+
uint32_t nprocs, n, k;
81+
pmix_info_t *info;
82+
bool flag;
83+
volatile int active;
84+
pmix_data_array_t da, *dptr;
85+
86+
/* init us - note that the call to "init" includes the return of
87+
* any job-related info provided by the RM. This includes any
88+
* debugger flag instructing us to stop-in-init. If such a directive
89+
* is included, then the process will be stopped in this call until
90+
* the "debugger release" notification arrives */
91+
if (PMIX_SUCCESS != (rc = PMIx_Init(&myproc, NULL, 0))) {
92+
fprintf(stderr, "Client ns %s rank %d: PMIx_Init failed: %d\n", myproc.nspace, myproc.rank, rc);
93+
exit(0);
94+
}
95+
fprintf(stderr, "Client ns %s rank %d: Running\n", myproc.nspace, myproc.rank);
96+
97+
98+
/* register our default event handler - again, this isn't strictly
99+
* required, but is generally good practice */
100+
active = -1;
101+
PMIx_Register_event_handler(NULL, 0, NULL, 0,
102+
notification_fn, evhandler_reg_callbk, (void*)&active);
103+
while (-1 == active) {
104+
sleep(1);
105+
}
106+
if (0 != active) {
107+
fprintf(stderr, "[%s:%d] Default handler registration failed\n", myproc.nspace, myproc.rank);
108+
exit(active);
109+
}
110+
111+
/* job-related info is found in our nspace, assigned to the
112+
* wildcard rank as it doesn't relate to a specific rank. Setup
113+
* a name to retrieve such values */
114+
PMIX_PROC_CONSTRUCT(&proc);
115+
(void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN);
116+
proc.rank = PMIX_RANK_WILDCARD;
117+
118+
/* get our job size */
119+
if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val))) {
120+
fprintf(stderr, "Client ns %s rank %d: PMIx_Get universe size failed: %d\n", myproc.nspace, myproc.rank, rc);
121+
goto done;
122+
}
123+
nprocs = val->data.uint32;
124+
PMIX_VALUE_RELEASE(val);
125+
fprintf(stderr, "Client %s:%d job size %d\n", myproc.nspace, myproc.rank, nprocs);
126+
127+
/* put a data array of pmix_value's */
128+
val = (pmix_value_t*)malloc(32 * sizeof(pmix_value_t));
129+
for (n=0; n < 32; n++) {
130+
val[n].type = PMIX_UINT64;
131+
val[n].data.uint64 = 2*n;
132+
}
133+
da.type = PMIX_VALUE;
134+
da.size = 32;
135+
da.array = val;
136+
value.type = PMIX_DATA_ARRAY;
137+
value.data.darray = &da;
138+
rc = PMIx_Put(PMIX_GLOBAL, "test-key", &value);
139+
if (PMIX_SUCCESS != rc) {
140+
fprintf(stderr, "Client ns %s rank %d: PMIx_Put failed: %d\n", myproc.nspace, myproc.rank, rc);
141+
goto done;
142+
}
143+
free(val);
144+
145+
/* push the data to our PMIx server */
146+
if (PMIX_SUCCESS != (rc = PMIx_Commit())) {
147+
fprintf(stderr, "Client ns %s rank %d: PMIx_Commit failed: %d\n", myproc.nspace, myproc.rank, rc);
148+
goto done;
149+
}
150+
151+
/* call fence to synchronize with our peers - instruct
152+
* the fence operation to collect and return all "put"
153+
* data from our peers */
154+
PMIX_INFO_CREATE(info, 1);
155+
flag = true;
156+
PMIX_INFO_LOAD(info, PMIX_COLLECT_DATA, &flag, PMIX_BOOL);
157+
if (PMIX_SUCCESS != (rc = PMIx_Fence(&proc, 1, info, 1))) {
158+
fprintf(stderr, "Client ns %s rank %d: PMIx_Fence failed: %d\n", myproc.nspace, myproc.rank, rc);
159+
goto done;
160+
}
161+
PMIX_INFO_FREE(info, 1);
162+
163+
/* check the returned data */
164+
for (n=0; n < nprocs; n++) {
165+
proc.rank = n;
166+
if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, "test-key", NULL, 0, &val))) {
167+
fprintf(stderr, "Client ns %s rank %d: PMIx_Get on rank %u failed: %d\n",
168+
myproc.nspace, myproc.rank, proc.rank, rc);
169+
goto done;
170+
}
171+
if (PMIX_DATA_ARRAY != val->type) {
172+
fprintf(stderr, "Client ns %s rank %d: PMIx_Get on rank %u returned wrong type: %d\n",
173+
myproc.nspace, myproc.rank, proc.rank, val->type);
174+
PMIX_VALUE_RELEASE(val);
175+
goto done;
176+
}
177+
dptr = val->data.darray;
178+
if (NULL == dptr) {
179+
fprintf(stderr, "Client ns %s rank %d: PMIx_Get %d returned NULL array\n",
180+
myproc.nspace, myproc.rank, proc.rank);
181+
PMIX_VALUE_RELEASE(val);
182+
goto done;
183+
}
184+
if (PMIX_VALUE != dptr->type) {
185+
fprintf(stderr, "Client ns %s rank %d: PMIx_Get %d returned wrong array value type %d\n",
186+
myproc.nspace, myproc.rank, proc.rank, dptr->type);
187+
PMIX_VALUE_RELEASE(val);
188+
goto done;
189+
}
190+
if (32 != dptr->size) {
191+
fprintf(stderr, "Client ns %s rank %d: PMIx_Get %d returned wrong array value size %d\n",
192+
myproc.nspace, myproc.rank, proc.rank, (int)dptr->size);
193+
PMIX_VALUE_RELEASE(val);
194+
goto done;
195+
}
196+
vptr = (pmix_value_t*)dptr->array;
197+
for (k=0; k < 32; k++) {
198+
if (PMIX_UINT64 != vptr[k].type) {
199+
fprintf(stderr, "Client ns %s rank %d: PMIx_Get %d returned wrong type: %d\n",
200+
myproc.nspace, myproc.rank, proc.rank, vptr[k].type);
201+
PMIX_VALUE_RELEASE(val);
202+
goto done;
203+
}
204+
if (2*k != vptr[k].data.uint64) {
205+
fprintf(stderr, "Client ns %s rank %d: PMIx_Get %d returned wrong value: %lu\n",
206+
myproc.nspace, myproc.rank, proc.rank, (unsigned long)vptr[k].data.uint64);
207+
PMIX_VALUE_RELEASE(val);
208+
goto done;
209+
}
210+
}
211+
}
212+
213+
done:
214+
/* finalize us */
215+
fprintf(stderr, "Client ns %s rank %d: Finalizing\n", myproc.nspace, myproc.rank);
216+
if (PMIX_SUCCESS != (rc = PMIx_Finalize(NULL, 0))) {
217+
fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize failed: %d\n", myproc.nspace, myproc.rank, rc);
218+
} else {
219+
fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize successfully completed\n", myproc.nspace, myproc.rank);
220+
}
221+
fflush(stderr);
222+
return(0);
223+
}

opal/mca/pmix/pmix2x/pmix/src/mca/bfrops/base/bfrop_base_pack.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,11 @@ pmix_status_t pmix_bfrops_base_pack_darray(pmix_buffer_t *buffer, const void *sr
990990
return ret;
991991
}
992992
break;
993+
case PMIX_VALUE:
994+
if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_value(buffer, p[i].array, p[i].size, PMIX_QUERY))) {
995+
return ret;
996+
}
997+
break;
993998
case PMIX_ALLOC_DIRECTIVE:
994999
if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_alloc_directive(buffer, p[i].array, p[i].size, PMIX_ALLOC_DIRECTIVE))) {
9951000
return ret;

opal/mca/pmix/pmix2x/pmix/src/mca/bfrops/base/bfrop_base_unpack.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,15 @@ pmix_status_t pmix_bfrops_base_unpack_darray(pmix_buffer_t *buffer, void *dest,
15151515
return ret;
15161516
}
15171517
break;
1518+
case PMIX_VALUE:
1519+
ptr[i].array = (pmix_value_t*)malloc(m * sizeof(pmix_value_t));
1520+
if (NULL == ptr[i].array) {
1521+
return PMIX_ERR_NOMEM;
1522+
}
1523+
if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_value(buffer, ptr[i].array, &m, ptr[i].type))) {
1524+
return ret;
1525+
}
1526+
break;
15181527
/**** DEPRECATED ****/
15191528
case PMIX_INFO_ARRAY:
15201529
ptr[i].array = (pmix_info_array_t*)malloc(m * sizeof(pmix_info_array_t));

opal/mca/pmix/pmix2x/pmix/src/mca/bfrops/v12/pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ pmix_status_t pmix12_bfrop_pack_app(pmix_buffer_t *buffer, const void *src,
707707
pmix_app_t *app;
708708
int32_t i, j, nvals;
709709
pmix_status_t ret;
710-
int argc;
710+
int argc=0;
711711

712712
app = (pmix_app_t *) src;
713713

0 commit comments

Comments
 (0)