1 /* -*- C -*-
2 *
3 * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
4 * University Research and Technology
5 * Corporation. All rights reserved.
6 * Copyright (c) 2004-2006 The University of Tennessee and The University
7 * of Tennessee Research Foundation. All rights
8 * reserved.
9 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10 * University of Stuttgart. All rights reserved.
11 * Copyright (c) 2004-2005 The Regents of the University of California.
12 * All rights reserved.
13 * Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
14 * Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
15 * Copyright (c) 2015 Research Organization for Information Science
16 * and Technology (RIST). All rights reserved.
17 * Copyright (c) 2018 IBM Corporation. All rights reserved.
18 * Copyright (c) 2019 Mellanox Technologies, Inc.
19 * All rights reserved.
20 * $COPYRIGHT$
21 *
22 * Additional copyrights may follow
23 *
24 * $HEADER$
25 *
26 */
27 #ifndef PMIX_GDS_BASE_H_
28 #define PMIX_GDS_BASE_H_
29
30 #include <src/include/pmix_config.h>
31
32
33 #ifdef HAVE_SYS_TIME_H
34 #include <sys/time.h> /* for struct timeval */
35 #endif
36 #ifdef HAVE_STRING_H
37 #include <string.h>
38 #endif
39
40 #include "src/class/pmix_list.h"
41 #include "src/mca/mca.h"
42 #include "src/mca/base/pmix_mca_base_framework.h"
43
44 #include "src/mca/gds/gds.h"
45
46
47 BEGIN_C_DECLS
48
49 /*
50 * MCA Framework
51 */
52 PMIX_EXPORT extern pmix_mca_base_framework_t pmix_gds_base_framework;
53 /**
54 * GDS select function
55 *
56 * Cycle across available components and construct the list
57 * of active modules
58 */
59 PMIX_EXPORT pmix_status_t pmix_gds_base_select(pmix_info_t info[], size_t ninfo);
60
61 /**
62 * Track an active component / module
63 */
64 struct pmix_gds_base_active_module_t {
65 pmix_list_item_t super;
66 int pri;
67 pmix_gds_base_module_t *module;
68 pmix_gds_base_component_t *component;
69 };
70 typedef struct pmix_gds_base_active_module_t pmix_gds_base_active_module_t;
71 PMIX_CLASS_DECLARATION(pmix_gds_base_active_module_t);
72
73
74 /* framework globals */
75 struct pmix_gds_globals_t {
76 pmix_list_t actives;
77 bool initialized;
78 char *all_mods;
79 };
80
81 typedef enum {
82 PMIX_MODEX_KEY_INVALID = -1,
83 PMIX_MODEX_KEY_NATIVE_FMT,
84 PMIX_MODEX_KEY_KEYMAP_FMT,
85 PMIX_MODEX_KEY_MAX
86 } pmix_gds_modex_key_fmt_t;
87
88 /* define a modex blob info */
89 typedef uint8_t pmix_gds_modex_blob_info_t;
90
91 #define PMIX_GDS_COLLECT_BIT 0x0001
92 #define PMIX_GDS_KEYMAP_BIT 0x0002
93
94 #define PMIX_GDS_KEYMAP_IS_SET(byte) (PMIX_GDS_KEYMAP_BIT & (byte))
95 #define PMIX_GDS_COLLECT_IS_SET(byte) (PMIX_GDS_COLLECT_BIT & (byte))
96
97 typedef struct pmix_gds_globals_t pmix_gds_globals_t;
98
99 typedef void * pmix_gds_base_ctx_t;
100 typedef pmix_status_t (*pmix_gds_base_store_modex_cb_fn_t)(pmix_gds_base_ctx_t ctx,
101 pmix_proc_t *proc,
102 pmix_gds_modex_key_fmt_t key_fmt,
103 char **kmap,
104 pmix_buffer_t *pbkt);
105
106 PMIX_EXPORT extern pmix_gds_globals_t pmix_gds_globals;
107
108 /* get a list of available support - caller must free results
109 * when done. The list is returned as a comma-delimited string
110 * of available components in priority order */
111 PMIX_EXPORT char* pmix_gds_base_get_available_modules(void);
112
113
114 /* Select a gds module based on the provided directives */
115 PMIX_EXPORT pmix_gds_base_module_t* pmix_gds_base_assign_module(pmix_info_t *info,
116 size_t ninfo);
117
118 /**
119 * Add any envars to a peer's environment that the module needs
120 * to communicate. The API stub will rotate across all active modules, giving
121 * each a chance to contribute
122 *
123 * @return PMIX_SUCCESS on success.
124 */
125 PMIX_EXPORT pmix_status_t pmix_gds_base_setup_fork(const pmix_proc_t *proc,
126 char ***env);
127
128 PMIX_EXPORT pmix_status_t pmix_gds_base_store_modex(struct pmix_namespace_t *nspace,
129 pmix_buffer_t * buff,
130 pmix_gds_base_ctx_t ctx,
131 pmix_gds_base_store_modex_cb_fn_t cb_fn,
132 void *cbdata);
133
134 PMIX_EXPORT
135 pmix_status_t pmix_gds_base_modex_pack_kval(pmix_gds_modex_key_fmt_t key_fmt,
136 pmix_buffer_t *buf, char ***kmap,
137 pmix_kval_t *kv);
138
139 PMIX_EXPORT
140 pmix_status_t pmix_gds_base_modex_unpack_kval(pmix_gds_modex_key_fmt_t key_fmt,
141 pmix_buffer_t *buf, char **kmap,
142 pmix_kval_t *kv);
143 END_C_DECLS
144
145 #endif