Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple commits #3145

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/pmix.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@ AC_DEFUN([PMIX_SETUP_CORE],[
pmix_config_prefix[src/tools/wrapper/Makefile]
pmix_config_prefix[src/tools/wrapper/pmixcc-wrapper-data.txt]
pmix_config_prefix[src/tools/palloc/Makefile]
pmix_config_prefix[src/tools/pctrl/Makefile]
)

# Success
Expand Down
11 changes: 10 additions & 1 deletion examples/pset.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Copyright (c) 2013-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved.
* Copyright (c) 2019 IBM Corporation. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* Copyright (c) 2021-2023 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -129,6 +129,7 @@ int main(int argc, char **argv)
mylock_t mylock;
myrel_t myrel;
pmix_info_t info;
pmix_value_t *val;

EXAMPLES_HIDE_UNUSED_PARAMS(argc, argv);

Expand Down Expand Up @@ -180,6 +181,14 @@ int main(int argc, char **argv)
}
DEBUG_DESTRUCT_MYREL(&myrel);

// check if I can retrieve my new pset membership
if (PMIX_SUCCESS != (rc = PMIx_Get(&myproc, PMIX_PSET_NAMES, NULL, 0, &val))) {
fprintf(stderr, "[%s:%d] PMIx_Get PMIX_PSET_NAMES returned %s\n", myproc.nspace,
myproc.rank, PMIx_Error_string(rc));
goto done;
}
fprintf(stderr, "[%s:%d] belongs to psets %s\n", myproc.nspace, myproc.rank, val->data.string);
PMIX_VALUE_RELEASE(val);

done:
/* finalize us */
Expand Down
6 changes: 6 additions & 0 deletions include/pmix.h
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,13 @@ PMIX_EXPORT pmix_value_cmp_t PMIx_Value_compare(pmix_value_t *v1,



PMIX_EXPORT void PMIx_Data_array_init(pmix_data_array_t *p,
pmix_data_type_t type);
PMIX_EXPORT void PMIx_Data_array_construct(pmix_data_array_t *p,
size_t num, pmix_data_type_t type);
PMIX_EXPORT void PMIx_Data_array_destruct(pmix_data_array_t *d);
PMIX_EXPORT pmix_data_array_t* PMIx_Data_array_create(size_t n, pmix_data_type_t type);
PMIX_EXPORT void PMIx_Data_array_free(pmix_data_array_t *p);


/* initialize an info struct */
Expand Down
1 change: 1 addition & 0 deletions include/pmix_common.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ typedef uint32_t pmix_rank_t;
#define PMIX_JOB_CTRL_PROVISION_IMAGE "pmix.jctrl.pvnimg" // (char*) name of the image that is to be provisioned
#define PMIX_JOB_CTRL_PREEMPTIBLE "pmix.jctrl.preempt" // (bool) job can be pre-empted
#define PMIX_JOB_CTRL_TERMINATE "pmix.jctrl.term" // (bool) politely terminate the specified procs
#define PMIX_JOB_CTRL_DEFINE_PSET "pmix.jctrl.defpset" // (char*) Pset name to be assigned to the targets
#define PMIX_REGISTER_CLEANUP "pmix.reg.cleanup" // (char*) comma-delimited list of files to
// be removed upon process termination
#define PMIX_REGISTER_CLEANUP_DIR "pmix.reg.cleanupdir" // (char*) comma-delimited list of directories to
Expand Down
88 changes: 86 additions & 2 deletions src/server/pmix_server_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Copyright (c) 2016 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2016 IBM Corporation. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* Copyright (c) 2021-2023 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -160,6 +160,8 @@ pmix_status_t pmix_server_get(pmix_buffer_t *buf, pmix_modex_cbfunc_t cbfunc, vo
struct timeval tv = {0, 0};
pmix_buffer_t pbkt;
pmix_cb_t cb;
pmix_kval_t *kval;
pmix_byte_object_t bo;
pmix_proc_t proc;
char *data;
size_t sz, n;
Expand Down Expand Up @@ -189,6 +191,8 @@ pmix_status_t pmix_server_get(pmix_buffer_t *buf, pmix_modex_cbfunc_t cbfunc, vo
PMIX_ERROR_LOG(rc);
return rc;
}
PMIX_LOAD_PROCID(&proc, nspace, rank);

/* retrieve any provided info structs */
cnt = 1;
PMIX_BFROPS_UNPACK(rc, cd->peer, buf, &cd->ninfo, &cnt, PMIX_SIZE);
Expand Down Expand Up @@ -236,6 +240,86 @@ pmix_status_t pmix_server_get(pmix_buffer_t *buf, pmix_modex_cbfunc_t cbfunc, vo
}
}

/* check for a request for pset names - these are not associated
* with a given nspace. Instead, we are searching for any psets
* that contain the calling process */
if (keyprovided && PMIx_Check_key(key, PMIX_PSET_NAMES)) {
/* loop over all known psets and collect names
* in which this proc is a member */
pmix_pset_t *pset;
char **psets = NULL;
PMIX_LIST_FOREACH(pset, &pmix_server_globals.psets, pmix_pset_t) {
for (n=0; n < pset->nmembers; n++) {
if (PMIx_Check_procid(&pset->members[n], &proc)) {
PMIx_Argv_append_nosize(&psets, pset->name);
break;
}
}
}
if (NULL != psets) {
data = PMIx_Argv_join(psets, ',');
PMIx_Argv_free(psets);
// pass it back
// we have to assemble this data into a form that
// the client_get function can properly unpack
PMIX_CONSTRUCT(&pbkt, pmix_buffer_t);
PMIX_CONSTRUCT(&cb, pmix_cb_t);
PMIX_KVAL_NEW(kval, PMIX_PSET_NAMES);
kval->value->data.string = data;
kval->value->type = PMIX_STRING;
pmix_list_append(&cb.kvs, &kval->super);
/* assemble the provided data into a byte object */
PMIX_GDS_ASSEMB_KVS_REQ(rc, pmix_globals.mypeer, &proc, &cb.kvs, &pbkt, cd);
if (rc != PMIX_SUCCESS) {
PMIX_ERROR_LOG(rc);
PMIX_DESTRUCT(&pbkt);
PMIX_DESTRUCT(&cb);
return rc;
}
PMIX_DESTRUCT(&cb);
if (PMIX_PEER_IS_V1(cd->peer)) {
/* if the client is using v1, then it expects the
* data returned to it as the rank followed by a byte object containing
* a buffer - so we have to do a little gyration */
pmix_buffer_t xfer;
PMIX_CONSTRUCT(&xfer, pmix_buffer_t);
PMIX_BFROPS_PACK(rc, cd->peer, &xfer, &pbkt, 1, PMIX_BUFFER);
if (PMIX_SUCCESS != rc) {
PMIX_ERROR_LOG(rc);
PMIX_DESTRUCT(&pbkt);
PMIX_DESTRUCT(&xfer);
PMIX_DESTRUCT(&cb);
return rc;
}
PMIX_UNLOAD_BUFFER(&xfer, bo.bytes, bo.size);
PMIX_DESTRUCT(&xfer);
} else {
PMIX_UNLOAD_BUFFER(&pbkt, bo.bytes, bo.size);
}
PMIX_DESTRUCT(&pbkt);
/* pack it for transmission */
PMIX_CONSTRUCT(&pbkt, pmix_buffer_t);
PMIX_BFROPS_PACK(rc, cd->peer, &pbkt, &bo, 1, PMIX_BYTE_OBJECT);
if (PMIX_SUCCESS != rc) {
PMIX_ERROR_LOG(rc);
PMIX_DESTRUCT(&pbkt);
return rc;
}
/* unload the resulting payload */
PMIX_UNLOAD_BUFFER(&pbkt, data, sz);
PMIX_DESTRUCT(&pbkt);
/* call the internal callback function - it will
* release the cbdata */
cbfunc(PMIX_SUCCESS, data, sz, cbdata, relfn, data);
/* return success so the server doesn't duplicate
* the release of cbdata */
return PMIX_SUCCESS;
} else {
// return not found as this proc doesn't belong to any psets
return PMIX_ERR_NOT_FOUND;
}
}

/* find the nspace object for the target proc */
nptr = NULL;
PMIX_LIST_FOREACH (ns, &pmix_globals.nspaces, pmix_namespace_t) {
Expand Down Expand Up @@ -703,7 +787,7 @@ static pmix_status_t get_job_data(char *nspace,
}
if (PMIX_PEER_IS_V1(cd->peer)) {
/* if the client is using v1, then it expects the
* data returned to it as the rank followed by abyte object containing
* data returned to it as the rank followed by a byte object containing
* a buffer - so we have to do a little gyration */
pmix_buffer_t xfer;
PMIX_CONSTRUCT(&xfer, pmix_buffer_t);
Expand Down
6 changes: 4 additions & 2 deletions src/tools/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ SUBDIRS += \
tools/pattrs \
tools/pquery \
tools/wrapper \
tools/palloc
tools/palloc \
tools/pctrl

DIST_SUBDIRS += \
tools/pevent \
Expand All @@ -43,4 +44,5 @@ DIST_SUBDIRS += \
tools/pattrs \
tools/pquery \
tools/wrapper \
tools/palloc
tools/palloc \
tools/pctrl
33 changes: 33 additions & 0 deletions src/tools/pctrl/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2009 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 (c) 2008-2014 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
# Copyright (c) 2017-2020 Intel, Inc. All rights reserved.
# Copyright (c) 2021-2023 Nanook Consulting. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#

if PMIX_INSTALL_BINARIES

bin_PROGRAMS = pctrl

dist_pmixdata_DATA = help-pctrl.txt

endif # PMIX_INSTALL_BINARIES

pctrl_SOURCES = pctrl.c
pctrl_LDADD = \
$(top_builddir)/src/libpmix.la
Loading