Skip to content

Commit 5c8fcab

Browse files
committed
Encode help-*.txt file contents into C source code
Encode the show_help text files into memory so that we don't have to find and open text files on-the-fly. This helps with relocation, although not strictly necessary. Biggest advantage is that we can supply show_help output from the very beginning, even if we haven't identified the text file directory. Enable access to the new system by PRRTE via a new API by which PRRTE can register its own in-memory array of help messages. Default to the internal PMIx array if show_help has yet to be initialized. Add a new "INMEMHELP" capability flag so that PRRTE can verify this PMIx version's support. Note that PRRTE will be updated so that the master branch and all release branches beginning with v4.0 can require it to build. Based on open-mpi/ompi#13144. Signed-off-by: Ralph Castain <[email protected]>
1 parent c4694cb commit 5c8fcab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+783
-588
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ src/tools/wrapper/pmixcc
143143

144144

145145
src/util/keyval/keyval_lex.c
146-
src/util/showhelp/showhelp_lex.c
146+
src/util/pmix_show_help_content.c
147147

148148
test/pmi2_client
149149
test/pmi_client

contrib/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Copyright (c) 2013-2016 Los Alamos National Security, Inc. All rights
1616
# reserved.
1717
# Copyright (c) 2013-2020 Intel, Inc. All rights reserved.
18-
# Copyright (c) 2022-2023 Nanook Consulting All rights reserved.
18+
# Copyright (c) 2022-2025 Nanook Consulting All rights reserved.
1919
# Copyright (c) 2024 Research Organization for Information Science
2020
# and Technology (RIST). All rights reserved.
2121
# $COPYRIGHT$

contrib/construct_dictionary.py

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Copyright (c) 2020 Intel, Inc. All rights reserved.
44
# Copyright (c) 2020-2022 Cisco Systems, Inc. All rights reserved
5-
# Copyright (c) 2021-2024 Nanook Consulting All rights reserved.
5+
# Copyright (c) 2021-2025 Nanook Consulting All rights reserved.
66
# Copyright (c) 2022 Triad National Security, LLC. All rights reserved.
77
# $COPYRIGHT$
88
#
@@ -11,11 +11,9 @@
1111
# by tools to interpret user input
1212
#
1313

14-
from __future__ import print_function
1514
import os
16-
import os.path
1715
import sys
18-
from optparse import OptionParser, OptionGroup
16+
import argparse
1917

2018
index = 0
2119

@@ -240,7 +238,7 @@ def harvest_constants(options, path, constants):
240238
return 0
241239

242240

243-
def _write_header(options, base_path, num_elements):
241+
def _write_header(options, num_elements):
244242
contents = '''/*
245243
* This file is autogenerated by construct_dictionary.py.
246244
* Do not edit this file by hand.
@@ -268,7 +266,7 @@ def _write_header(options, base_path, num_elements):
268266
constants = sys.stdout
269267
outpath = None
270268
else:
271-
outpath = os.path.join(base_path, "pmix_dictionary.h")
269+
outpath = os.path.join(options.out, "pmix_dictionary.h")
272270
try:
273271
constants = open(outpath, "w+")
274272
except Exception as e:
@@ -281,44 +279,26 @@ def _write_header(options, base_path, num_elements):
281279

282280

283281
def main():
284-
parser = OptionParser("usage: %prog [options]")
285-
debugGroup = OptionGroup(parser, "Debug Options")
286-
debugGroup.add_option("--dryrun",
287-
action="store_true", dest="dryrun", default=False,
288-
help="Show output to screen")
289-
parser.add_option_group(debugGroup)
290-
291-
(options, args) = parser.parse_args()
292-
293-
# Find the top-level PMIx source tree dir.
294-
# Start with the location of this script, which we know is in
295-
# $top_srcdir/contrib.
296-
top_src_dir = os.path.dirname(sys.argv[0])
297-
top_src_dir = os.path.join(top_src_dir, "..")
298-
top_src_dir = os.path.abspath(top_src_dir)
299-
300-
# Sanity check
301-
checkfile = os.path.join(top_src_dir, "VERSION")
302-
if not os.path.exists(checkfile):
303-
print("ERROR: Could not find top source directory for Open PMIx")
304-
return 1
305-
306-
source_include_dir = os.path.join(top_src_dir, "include")
307-
308-
# This script is invoked from src/include/Makefile.am, and
309-
# therefore the cwd will be $(builddir)/src/include. Verify this
310-
# by checking for a file that we know should be in there.
311-
build_src_include_dir = os.getcwd()
312-
checkfile = os.path.join(build_src_include_dir, "pmix_config.h")
313-
if not os.path.exists(checkfile):
314-
print("ERROR: Could not find build directory for Open PMIx")
315-
return 1
316-
317-
if options.dryrun:
282+
parser = argparse.ArgumentParser(description="Generate attribute dictionary.")
283+
parser.add_argument("--root",
284+
required=True,
285+
help="Root directory of code tree")
286+
parser.add_argument("--out",
287+
required=True,
288+
help="Output C file")
289+
parser.add_argument("--dryrun",
290+
action="store_true",
291+
help="Do not write out resulting file")
292+
293+
args = parser.parse_args()
294+
295+
source_include_dir = os.path.join(args.root, "include")
296+
297+
if args.dryrun:
318298
constants = sys.stdout
319299
outpath = None
320300
else:
321-
outpath = os.path.join(build_src_include_dir, "pmix_dictionary.c")
301+
outpath = os.path.join(args.out, "pmix_dictionary.c")
322302
try:
323303
constants = open(outpath, "w+")
324304
except Exception as e:
@@ -341,7 +321,7 @@ def main():
341321
# looking for constants and typedefs
342322

343323
# pmix_common.h.in is in the src tree
344-
rc = harvest_constants(options,
324+
rc = harvest_constants(args,
345325
os.path.join(source_include_dir, "pmix_common.h.in"),
346326
constants)
347327
if 0 != rc:
@@ -353,7 +333,7 @@ def main():
353333
constants.write(",\n")
354334

355335
# pmix_deprecated.h is in the source tree
356-
rc = harvest_constants(options,
336+
rc = harvest_constants(args,
357337
os.path.join(source_include_dir, "pmix_deprecated.h"),
358338
constants)
359339
if 0 != rc:
@@ -369,7 +349,7 @@ def main():
369349
constants.close()
370350

371351
# write the header
372-
return _write_header(options, build_src_include_dir, index)
352+
return _write_header(args, index)
373353

374354

375355
if __name__ == '__main__':

include/pmix_version.h.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,16 @@
3939
/* Individual capability flags */
4040
#define PMIX_CAP_BASE 1
4141
#define PMIX_CAP_LTO 2
42+
#define PMIX_CAP_INMEMHELP 3
4243

4344

4445
/* These are the capabilities that this version of OpenPMIx has.
4546
* For now, we just define/use a "base" marker as a starting
4647
* point
4748
*/
4849
#define PMIX_CAPABILITIES \
49-
(PMIX_CAP_BASE | PMIX_CAP_LTO)
50+
(PMIX_CAP_BASE | \
51+
PMIX_CAP_LTO | \
52+
PMIX_CAP_INMEMHELP)
5053

5154
#endif

src/Makefile.am

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Copyright (c) 2013-2020 Intel, Inc. All rights reserved.
1515
# Copyright (c) 2021 Amazon.com, Inc. or its affiliates.
1616
# All Rights reserved.
17-
# Copyright (c) 2021-2022 Nanook Consulting All rights reserved.
17+
# Copyright (c) 2021-2025 Nanook Consulting All rights reserved.
1818
# $COPYRIGHT$
1919
#
2020
# Additional copyrights may follow
@@ -46,7 +46,6 @@ headers =
4646
sources =
4747
nodist_headers =
4848
EXTRA_DIST =
49-
dist_pmixdata_DATA =
5049
nobase_pmix_HEADERS =
5150
pmixdir = $(pmixincludedir)/$(subdir)
5251

src/common/Makefile.include

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
#
33
# Copyright (c) 2015-2019 Intel, Inc. All rights reserved.
44
# Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
5-
# Copyright (c) 2023-2024 Nanook Consulting All rights reserved.
5+
# Copyright (c) 2023-2025 Nanook Consulting All rights reserved.
66
# $COPYRIGHT$
77
#
88
# Additional copyrights may follow
99
#
1010
# $HEADER$
1111
#
1212

13-
dist_pmixdata_DATA += \
13+
EXTRA_DIST += \
1414
common/help-pfexec-base.txt
1515

1616
sources += \

src/common/pfexec_linux.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static int write_help_msg(int fd, pmix_pfexec_pipe_err_msg_t *msg, const char *f
243243
return PMIX_ERR_BAD_PARAM;
244244
}
245245

246-
str = pmix_show_help_vstring(file, topic, true, ap);
246+
str = pmix_show_help_vstring("pmix", file, topic, true, ap);
247247

248248
msg->file_str_len = (int) strlen(file);
249249
if (msg->file_str_len > PMIX_PFEXEC_MAX_FILE_LEN) {
@@ -460,7 +460,7 @@ static pmix_status_t do_parent(pmix_app_t *app, pmix_pfexec_child_t *child, int
460460
if (msg.file_str_len > 0) {
461461
rc = pmix_fd_read(read_fd, msg.file_str_len, file);
462462
if (PMIX_SUCCESS != rc) {
463-
pmix_show_help("help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
463+
pmix_show_help("pmix", "help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
464464
app->cmd, "pmix_fd_read", __FILE__, __LINE__);
465465
return rc;
466466
}
@@ -469,7 +469,7 @@ static pmix_status_t do_parent(pmix_app_t *app, pmix_pfexec_child_t *child, int
469469
if (msg.topic_str_len > 0) {
470470
rc = pmix_fd_read(read_fd, msg.topic_str_len, topic);
471471
if (PMIX_SUCCESS != rc) {
472-
pmix_show_help("help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
472+
pmix_show_help("pmix", "help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
473473
app->cmd, "pmix_fd_read", __FILE__, __LINE__);
474474
return rc;
475475
}
@@ -478,13 +478,13 @@ static pmix_status_t do_parent(pmix_app_t *app, pmix_pfexec_child_t *child, int
478478
if (msg.msg_str_len > 0) {
479479
str = calloc(1, msg.msg_str_len + 1);
480480
if (NULL == str) {
481-
pmix_show_help("help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
481+
pmix_show_help("pmix", "help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
482482
app->cmd, "calloc", __FILE__, __LINE__);
483483
return PMIX_ERR_NOMEM;
484484
}
485485
rc = pmix_fd_read(read_fd, msg.msg_str_len, str);
486486
if (PMIX_SUCCESS != rc) {
487-
pmix_show_help("help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
487+
pmix_show_help("pmix", "help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
488488
app->cmd, "pmix_fd_read", __FILE__, __LINE__);
489489
free(str);
490490
return rc;
@@ -493,7 +493,7 @@ static pmix_status_t do_parent(pmix_app_t *app, pmix_pfexec_child_t *child, int
493493
}
494494

495495
/* Print out what we got. We already have a rendered string,
496-
so use pmix_show_help_norender(). */
496+
so just print it. */
497497
if (msg.msg_str_len > 0) {
498498
fprintf(stderr, "%s\n", str);
499499
free(str);

src/common/pmix_pfexec.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ void pmix_pfexec_base_spawn_proc(int sd, short args, void *cbdata)
339339
}
340340
app->cmd = pmix_path_findv(argv[0], X_OK, app->env, NULL);
341341
if (NULL == app->cmd) {
342-
pmix_show_help("help-pfexec-base.txt", "fork-agent-not-found", true,
342+
pmix_show_help("pmix", "help-pfexec-base.txt", "fork-agent-not-found", true,
343343
pmix_globals.hostname, argv[0]);
344344
rc = PMIX_ERR_NOT_FOUND;
345345
PMIx_Argv_free(argv);
@@ -912,7 +912,7 @@ static int write_help_msg(int fd, pmix_pfexec_pipe_err_msg_t *msg, const char *f
912912
return PMIX_ERR_BAD_PARAM;
913913
}
914914

915-
str = pmix_show_help_vstring(file, topic, true, ap);
915+
str = pmix_show_help_vstring("pmix", file, topic, true, ap);
916916

917917
msg->file_str_len = (int) strlen(file);
918918
if (msg->file_str_len > PMIX_PFEXEC_MAX_FILE_LEN) {
@@ -1129,7 +1129,7 @@ static pmix_status_t do_parent(pmix_app_t *app, pmix_pfexec_child_t *child, int
11291129
if (msg.file_str_len > 0) {
11301130
rc = pmix_fd_read(read_fd, msg.file_str_len, file);
11311131
if (PMIX_SUCCESS != rc) {
1132-
pmix_show_help("help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
1132+
pmix_show_help("pmix", "help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
11331133
app->cmd, "pmix_fd_read", __FILE__, __LINE__);
11341134
return rc;
11351135
}
@@ -1138,7 +1138,7 @@ static pmix_status_t do_parent(pmix_app_t *app, pmix_pfexec_child_t *child, int
11381138
if (msg.topic_str_len > 0) {
11391139
rc = pmix_fd_read(read_fd, msg.topic_str_len, topic);
11401140
if (PMIX_SUCCESS != rc) {
1141-
pmix_show_help("help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
1141+
pmix_show_help("pmix", "help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
11421142
app->cmd, "pmix_fd_read", __FILE__, __LINE__);
11431143
return rc;
11441144
}
@@ -1147,13 +1147,13 @@ static pmix_status_t do_parent(pmix_app_t *app, pmix_pfexec_child_t *child, int
11471147
if (msg.msg_str_len > 0) {
11481148
str = calloc(1, msg.msg_str_len + 1);
11491149
if (NULL == str) {
1150-
pmix_show_help("help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
1150+
pmix_show_help("pmix", "help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
11511151
app->cmd, "calloc", __FILE__, __LINE__);
11521152
return PMIX_ERR_NOMEM;
11531153
}
11541154
rc = pmix_fd_read(read_fd, msg.msg_str_len, str);
11551155
if (PMIX_SUCCESS != rc) {
1156-
pmix_show_help("help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
1156+
pmix_show_help("pmix", "help-pfexec-base.txt", "syscall fail", true, pmix_globals.hostname,
11571157
app->cmd, "pmix_fd_read", __FILE__, __LINE__);
11581158
free(str);
11591159
return rc;
@@ -1162,7 +1162,7 @@ static pmix_status_t do_parent(pmix_app_t *app, pmix_pfexec_child_t *child, int
11621162
}
11631163

11641164
/* Print out what we got. We already have a rendered string,
1165-
so use pmix_show_help_norender(). */
1165+
so just print it. */
11661166
if (msg.msg_str_len > 0) {
11671167
fprintf(stderr, "%s\n", str);
11681168
free(str);

src/hwloc/Makefile.include

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# -*- makefile -*-
22
#
33
# Copyright (c) 2016 Intel, Inc. All rights reserved.
4-
# Copyright (c) 2021 Nanook Consulting. All rights reserved.
4+
# Copyright (c) 2021-2025 Nanook Consulting All rights reserved.
55
# $COPYRIGHT$
66
#
77
# Additional copyrights may follow
88
#
99
# $HEADER$
1010

11-
dist_pmixdata_DATA += hwloc/help-ploc.txt
11+
EXTRA_DIST += hwloc/help-ploc.txt
1212

1313
headers += \
1414
hwloc/pmix_hwloc.h

src/hwloc/pmix_hwloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ pmix_status_t pmix_hwloc_setup_topology(pmix_info_t *info, size_t ninfo)
528528
}
529529
if (!space_available) {
530530
if (1 < pmix_output_get_verbosity(pmix_hwloc_output)) {
531-
pmix_show_help("help-ploc.txt", "target full", true, shmemfile,
531+
pmix_show_help("pmix", "help-ploc.txt", "target full", true, shmemfile,
532532
pmix_globals.hostname, (unsigned long) shmemsize,
533533
(unsigned long long) amount_space_avail);
534534
}
@@ -540,7 +540,7 @@ pmix_status_t pmix_hwloc_setup_topology(pmix_info_t *info, size_t ninfo)
540540
if (-1 == (shmemfd = open(shmemfile, O_CREAT | O_RDWR, 0600))) {
541541
int err = errno;
542542
if (1 < pmix_output_get_verbosity(pmix_hwloc_output)) {
543-
pmix_show_help("help-ploc.txt", "sys call fail", true,
543+
pmix_show_help("pmix", "help-ploc.txt", "sys call fail", true,
544544
pmix_globals.hostname, "open(2)", "", strerror(err), err);
545545
}
546546
free(shmemfile);

src/include/Makefile.am

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Copyright (c) 2007-2022 Cisco Systems, Inc. All rights reserved
1515
# Copyright (c) 2017 Research Organization for Information Science
1616
# and Technology (RIST). All rights reserved.
17-
# Copyright (c) 2021-2023 Nanook Consulting. All rights reserved.
17+
# Copyright (c) 2021-2025 Nanook Consulting All rights reserved.
1818
# Copyright (c) 2022-2023 Triad National Security, LLC. All rights reserved.
1919
# $COPYRIGHT$
2020
#
@@ -42,6 +42,8 @@
4242
# file corruption issue is an acceptable tradeoff.
4343
.NOTPARALLEL:
4444

45+
include $(top_srcdir)/Makefile.openpmix-rules
46+
4547
AM_CFLAGS = \
4648
-DPMIX_PROXY_VERSION_STRING="\"@PMIX_VERSION@\"" \
4749
-DPMIX_PROXY_BUGREPORT_STRING="\"@PMIX_PROXY_BUGREPORT_STRING@\""
@@ -85,14 +87,17 @@ libpmixglobal_gen = \
8587
pmix_event_strings.h \
8688
pmix_event_strings.c
8789

90+
8891
# Need to ensure that pmix_dictionary.h and pmix_dictionary.c are built first --
8992
# before any other targets.
9093
BUILT_SOURCES = $(libpmixglobal_gen)
9194

92-
$(libpmixglobal_gen): $(top_srcdir)/include/pmix_common.h.in \
93-
$(top_srcdir)/include/pmix_deprecated.h \
94-
$(top_srcdir)/src/common/pmix_attributes.c
95-
$(PYTHON) $(top_srcdir)/contrib/construct_dictionary.py
96-
$(PYTHON) $(top_srcdir)/contrib/construct_event_strings.py
95+
$(libpmixglobal_gen): $(abs_top_srcdir)/include/pmix_common.h.in \
96+
$(abs_top_srcdir)/include/pmix_deprecated.h \
97+
$(abs_top_srcdir)/src/common/pmix_attributes.c
98+
$(PMIX_V_GEN) $(PYTHON) $(abs_top_srcdir)/contrib/construct_dictionary.py \
99+
--root $(abs_top_srcdir) \
100+
--out .
101+
$(PMIX_V_GEN) $(PYTHON) $(abs_top_srcdir)/contrib/construct_event_strings.py
97102

98103
MAINTAINERCLEANFILES = $(libpmixglobal_gen)

0 commit comments

Comments
 (0)