root/orte/orted/pmix/pmix_server_internal.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2006 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) 2010-2011 Cisco Systems, Inc.  All rights reserved.
  15  * Copyright (c) 2013-2018 Intel, Inc.  All rights reserved.
  16  * Copyright (c) 2014      Mellanox Technologies, Inc.
  17  *                         All rights reserved.
  18  * Copyright (c) 2014      Research Organization for Information Science
  19  *                         and Technology (RIST). All rights reserved.
  20  * $COPYRIGHT$
  21  *
  22  * Additional copyrights may follow
  23  *
  24  * $HEADER$
  25  */
  26 
  27 #ifndef _PMIX_SERVER_INTERNAL_H_
  28 #define _PMIX_SERVER_INTERNAL_H_
  29 
  30 #include "orte_config.h"
  31 #include "orte/types.h"
  32 
  33 #ifdef HAVE_SYS_SOCKET_H
  34 #include <sys/socket.h>
  35 #endif
  36 #ifdef HAVE_SYS_UN_H
  37 #include <sys/un.h>
  38 #endif
  39 
  40 #include "opal/types.h"
  41 #include "opal/class/opal_hotel.h"
  42 #include "opal/mca/base/base.h"
  43 #include "opal/mca/event/event.h"
  44 #include "opal/mca/pmix/pmix.h"
  45 #include "opal/util/printf.h"
  46 #include "opal/util/proc.h"
  47 #include "opal/sys/atomic.h"
  48 
  49 #include "orte/mca/grpcomm/base/base.h"
  50 #include "orte/runtime/orte_globals.h"
  51 #include "orte/util/threads.h"
  52 
  53 BEGIN_C_DECLS
  54 
  55 #define ORTED_PMIX_MIN_DMX_TIMEOUT      10
  56 #define ORTE_ADJUST_TIMEOUT(a)                                      \
  57     do {                                                            \
  58         (a)->timeout = (2 * orte_process_info.num_daemons) / 1000;  \
  59         if ((a)->timeout < ORTED_PMIX_MIN_DMX_TIMEOUT) {            \
  60             (a)->timeout = ORTED_PMIX_MIN_DMX_TIMEOUT;              \
  61         }                                                           \
  62     } while(0)
  63 
  64 /* object for tracking requests so we can
  65  * correctly route the eventual reply */
  66  typedef struct {
  67     opal_object_t super;
  68     opal_event_t ev;
  69     char *operation;
  70     int status;
  71     int timeout;
  72     int room_num;
  73     int remote_room_num;
  74     opal_pmix_data_range_t range;
  75     orte_process_name_t proxy;
  76     orte_process_name_t target;
  77     orte_job_t *jdata;
  78     opal_buffer_t msg;
  79     opal_pmix_op_cbfunc_t opcbfunc;
  80     opal_pmix_modex_cbfunc_t mdxcbfunc;
  81     opal_pmix_spawn_cbfunc_t spcbfunc;
  82     opal_pmix_lookup_cbfunc_t lkcbfunc;
  83     opal_pmix_release_cbfunc_t rlcbfunc;
  84     void *cbdata;
  85 } pmix_server_req_t;
  86 OBJ_CLASS_DECLARATION(pmix_server_req_t);
  87 
  88 /* object for thread-shifting server operations */
  89 typedef struct {
  90     opal_object_t super;
  91     opal_event_t ev;
  92     int status;
  93     opal_process_name_t proc;
  94     const char *msg;
  95     void *server_object;
  96     opal_list_t *procs;
  97     opal_list_t *eprocs;
  98     opal_list_t *info;
  99     opal_pmix_op_cbfunc_t cbfunc;
 100     opal_pmix_info_cbfunc_t infocbfunc;
 101     opal_pmix_tool_connection_cbfunc_t toolcbfunc;
 102     void *cbdata;
 103 } orte_pmix_server_op_caddy_t;
 104 OBJ_CLASS_DECLARATION(orte_pmix_server_op_caddy_t);
 105 
 106 typedef struct {
 107     opal_object_t super;
 108     orte_grpcomm_signature_t *sig;
 109     opal_pmix_modex_cbfunc_t cbfunc;
 110     void *cbdata;
 111 } orte_pmix_mdx_caddy_t;
 112 OBJ_CLASS_DECLARATION(orte_pmix_mdx_caddy_t);
 113 
 114 #define ORTE_DMX_REQ(p, cf, ocf, ocd)                       \
 115     do {                                                     \
 116         pmix_server_req_t *_req;                             \
 117         _req = OBJ_NEW(pmix_server_req_t);                   \
 118         opal_asprintf(&_req->operation, "DMDX: %s:%d", __FILE__, __LINE__); \
 119         _req->target = (p);                                  \
 120         _req->mdxcbfunc = (ocf);                             \
 121         _req->cbdata = (ocd);                                \
 122         opal_event_set(orte_event_base, &(_req->ev),         \
 123                        -1, OPAL_EV_WRITE, (cf), _req);       \
 124         opal_event_set_priority(&(_req->ev), ORTE_MSG_PRI);  \
 125         ORTE_POST_OBJECT(_req);                              \
 126         opal_event_active(&(_req->ev), OPAL_EV_WRITE, 1);    \
 127     } while(0);
 128 
 129 #define ORTE_SPN_REQ(j, cf, ocf, ocd)                       \
 130     do {                                                     \
 131         pmix_server_req_t *_req;                             \
 132         _req = OBJ_NEW(pmix_server_req_t);                   \
 133         opal_asprintf(&_req->operation, "SPAWN: %s:%d", __FILE__, __LINE__); \
 134         _req->jdata = (j);                                   \
 135         _req->spcbfunc = (ocf);                              \
 136         _req->cbdata = (ocd);                                \
 137         opal_event_set(orte_event_base, &(_req->ev),         \
 138                        -1, OPAL_EV_WRITE, (cf), _req);       \
 139         opal_event_set_priority(&(_req->ev), ORTE_MSG_PRI);  \
 140         ORTE_POST_OBJECT(_req);                              \
 141         opal_event_active(&(_req->ev), OPAL_EV_WRITE, 1);    \
 142     } while(0);
 143 
 144 #define ORTE_PMIX_OPERATION(p, i, fn, cf, cb)                   \
 145     do {                                                        \
 146         orte_pmix_server_op_caddy_t *_cd;                       \
 147         _cd = OBJ_NEW(orte_pmix_server_op_caddy_t);             \
 148         _cd->procs = (p);                                       \
 149         _cd->info = (i);                                        \
 150         _cd->cbfunc = (cf);                                     \
 151         _cd->cbdata = (cb);                                     \
 152         opal_event_set(orte_event_base, &(_cd->ev), -1,         \
 153                        OPAL_EV_WRITE, (fn), _cd);               \
 154         opal_event_set_priority(&(_cd->ev), ORTE_MSG_PRI);      \
 155         ORTE_POST_OBJECT(_cd);                                  \
 156         opal_event_active(&(_cd->ev), OPAL_EV_WRITE, 1);        \
 157     } while(0);
 158 
 159 #define ORTE_PMIX_THREADSHIFT(p, s, st, m, pl, fn, cf, cb)      \
 160     do {                                                        \
 161         orte_pmix_server_op_caddy_t *_cd;                       \
 162         _cd = OBJ_NEW(orte_pmix_server_op_caddy_t);             \
 163         _cd->proc.jobid = (p)->jobid;                           \
 164         _cd->proc.vpid = (p)->vpid;                             \
 165         _cd->server_object = (s);                               \
 166         _cd->status = (st);                                     \
 167         _cd->msg = (m);                                         \
 168         _cd->procs = (pl);                                      \
 169         _cd->cbfunc = (cf);                                     \
 170         _cd->cbdata = (cb);                                     \
 171         opal_event_set(orte_event_base, &(_cd->ev), -1,         \
 172                        OPAL_EV_WRITE, (fn), _cd);               \
 173         opal_event_set_priority(&(_cd->ev), ORTE_MSG_PRI);      \
 174         ORTE_POST_OBJECT(_cd);                                  \
 175         opal_event_active(&(_cd->ev), OPAL_EV_WRITE, 1);        \
 176     } while(0);
 177 
 178 /* define the server module functions */
 179 extern int pmix_server_client_connected_fn(opal_process_name_t *proc, void* server_object,
 180                                            opal_pmix_op_cbfunc_t cbfunc, void *cbdata);
 181 extern int pmix_server_client_finalized_fn(opal_process_name_t *proc, void* server_object,
 182                                            opal_pmix_op_cbfunc_t cbfunc, void *cbdata);
 183 extern int pmix_server_abort_fn(opal_process_name_t *proc, void *server_object,
 184                                 int status, const char msg[],
 185                                 opal_list_t *procs_to_abort,
 186                                 opal_pmix_op_cbfunc_t cbfunc, void *cbdata);
 187 extern int pmix_server_fencenb_fn(opal_list_t *procs, opal_list_t *info,
 188                                   char *data, size_t ndata,
 189                                   opal_pmix_modex_cbfunc_t cbfunc, void *cbdata);
 190 extern int pmix_server_dmodex_req_fn(opal_process_name_t *proc, opal_list_t *info,
 191                                      opal_pmix_modex_cbfunc_t cbfunc, void *cbdata);
 192 extern int pmix_server_publish_fn(opal_process_name_t *proc,
 193                                   opal_list_t *info,
 194                                   opal_pmix_op_cbfunc_t cbfunc, void *cbdata);
 195 extern int pmix_server_lookup_fn(opal_process_name_t *proc, char **keys,
 196                                  opal_list_t *info,
 197                                  opal_pmix_lookup_cbfunc_t cbfunc, void *cbdata);
 198 extern int pmix_server_unpublish_fn(opal_process_name_t *proc, char **keys,
 199                                     opal_list_t *info,
 200                                     opal_pmix_op_cbfunc_t cbfunc, void *cbdata);
 201 extern int pmix_server_spawn_fn(opal_process_name_t *requestor,
 202                                 opal_list_t *job_info, opal_list_t *apps,
 203                                 opal_pmix_spawn_cbfunc_t cbfunc, void *cbdata);
 204 extern int pmix_server_connect_fn(opal_list_t *procs, opal_list_t *info,
 205                                   opal_pmix_op_cbfunc_t cbfunc, void *cbdata);
 206 extern int pmix_server_disconnect_fn(opal_list_t *procs, opal_list_t *info,
 207                                      opal_pmix_op_cbfunc_t cbfunc, void *cbdata);
 208 extern int pmix_server_register_events_fn(opal_list_t *info,
 209                                           opal_pmix_op_cbfunc_t cbfunc,
 210                                           void *cbdata);
 211 extern int pmix_server_deregister_events_fn(opal_list_t *info,
 212                                             opal_pmix_op_cbfunc_t cbfunc,
 213                                             void *cbdata);
 214 extern int pmix_server_notify_event(int code, opal_process_name_t *source,
 215                                     opal_list_t *info,
 216                                     opal_pmix_op_cbfunc_t cbfunc, void *cbdata);
 217 extern int pmix_server_query_fn(opal_process_name_t *requestor,
 218                                 opal_list_t *queries,
 219                                 opal_pmix_info_cbfunc_t cbfunc, void *cbdata);
 220 extern void pmix_tool_connected_fn(opal_list_t *info,
 221                                    opal_pmix_tool_connection_cbfunc_t cbfunc,
 222                                    void *cbdata);
 223 
 224 extern void pmix_server_log_fn(opal_process_name_t *requestor,
 225                                opal_list_t *info,
 226                                opal_list_t *directives,
 227                                opal_pmix_op_cbfunc_t cbfunc,
 228                                void *cbdata);
 229 
 230 extern int pmix_server_alloc_fn(const opal_process_name_t *requestor,
 231                                 opal_pmix_alloc_directive_t dir,
 232                                 opal_list_t *info,
 233                                 opal_pmix_info_cbfunc_t cbfunc,
 234                                 void *cbdata);
 235 
 236 extern int pmix_server_job_ctrl_fn(const opal_process_name_t *requestor,
 237                                    opal_list_t *targets,
 238                                    opal_list_t *info,
 239                                    opal_pmix_info_cbfunc_t cbfunc,
 240                                    void *cbdata);
 241 
 242 /* declare the RML recv functions for responses */
 243 extern void pmix_server_launch_resp(int status, orte_process_name_t* sender,
 244                                     opal_buffer_t *buffer,
 245                                     orte_rml_tag_t tg, void *cbdata);
 246 
 247 extern void pmix_server_keyval_client(int status, orte_process_name_t* sender,
 248                                       opal_buffer_t *buffer,
 249                                       orte_rml_tag_t tg, void *cbdata);
 250 
 251 extern void pmix_server_notify(int status, orte_process_name_t* sender,
 252                                opal_buffer_t *buffer,
 253                                orte_rml_tag_t tg, void *cbdata);
 254 
 255 /* exposed shared variables */
 256 typedef struct {
 257     bool initialized;
 258     int verbosity;
 259     int output;
 260     opal_hotel_t reqs;
 261     int num_rooms;
 262     int timeout;
 263     bool wait_for_server;
 264     orte_process_name_t server;
 265     opal_list_t notifications;
 266     bool pubsub_init;
 267     bool session_server;
 268     bool system_server;
 269     bool legacy;
 270 } pmix_server_globals_t;
 271 
 272 extern pmix_server_globals_t orte_pmix_server_globals;
 273 
 274 END_C_DECLS
 275 
 276 #endif /* PMIX_SERVER_INTERNAL_H_ */

/* [<][>][^][v][top][bottom][index][help] */