Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 10:12:56

0001 /*
0002  * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
0003  *                         University Research and Technology
0004  *                         Corporation.  All rights reserved.
0005  * Copyright (c) 2004-2011 The University of Tennessee and The University
0006  *                         of Tennessee Research Foundation.  All rights
0007  *                         reserved.
0008  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
0009  *                         University of Stuttgart.  All rights reserved.
0010  * Copyright (c) 2004-2005 The Regents of the University of California.
0011  *                         All rights reserved.
0012  * Copyright (c) 2011-2020 Cisco Systems, Inc.  All rights reserved
0013  * Copyright (c) 2013      Los Alamos National Security, LLC.  All rights reserved.
0014  * Copyright (c) 2017-2019 Intel, Inc.  All rights reserved.
0015  * Copyright (c) 2021-2023 Nanook Consulting.  All rights reserved.
0016  * $COPYRIGHT$
0017  *
0018  * Additional copyrights may follow
0019  *
0020  * $HEADER$
0021  */
0022 /** @file:
0023  */
0024 
0025 #ifndef MCA_ODLS_BASE_H
0026 #define MCA_ODLS_BASE_H
0027 
0028 /*
0029  * includes
0030  */
0031 #include "prte_config.h"
0032 
0033 #include "src/mca/mca.h"
0034 #include "src/mca/base/pmix_mca_base_framework.h"
0035 #include "src/mca/iof/base/iof_base_setup.h"
0036 #include "src/mca/odls/odls.h"
0037 
0038 BEGIN_C_DECLS
0039 
0040 /*
0041  * General ODLS types
0042  */
0043 
0044 typedef struct {
0045     /** Verbose/debug output stream */
0046     int output;
0047     /* list of ranks to be displayed on separate xterms */
0048     pmix_list_t xterm_ranks;
0049     /* the xterm cmd to be used */
0050     char **xtermcmd;
0051     /* thread pool */
0052     int max_threads;
0053     int num_threads;
0054     int cutoff;
0055     prte_event_base_t **ev_bases; // event base array for progress threads
0056     char **ev_threads;            // event progress thread names
0057     int next_base;                // counter to load-level thread use
0058     bool signal_direct_children_only;
0059     pmix_lock_t lock;
0060     char *exec_agent;
0061 } prte_odls_globals_t;
0062 
0063 PRTE_EXPORT extern prte_odls_globals_t prte_odls_globals;
0064 
0065 /*
0066  * MCA framework
0067  */
0068 PRTE_EXPORT extern pmix_mca_base_framework_t prte_odls_base_framework;
0069 /*
0070  * Select an available component.
0071  */
0072 PRTE_EXPORT int prte_odls_base_select(void);
0073 
0074 /*
0075  * Default functions that are common to most environments - can
0076  * be overridden by specific environments if they need something
0077  * different (e.g., bproc)
0078  */
0079 PRTE_EXPORT int prte_odls_base_default_get_add_procs_data(pmix_data_buffer_t *data,
0080                                                           pmix_nspace_t job);
0081 
0082 PRTE_EXPORT int prte_odls_base_default_construct_child_list(pmix_data_buffer_t *data,
0083                                                             pmix_nspace_t *job);
0084 
0085 PRTE_EXPORT void prte_odls_base_spawn_proc(int fd, short sd, void *cbdata);
0086 
0087 /* define a function that will fork a local proc */
0088 typedef int (*prte_odls_base_fork_local_proc_fn_t)(void *cd);
0089 
0090 /* define an object for fork/exec the local proc */
0091 typedef struct {
0092     pmix_object_t super;
0093     prte_event_t ev;
0094     char *cmd;
0095     char *wdir;
0096     char **argv;
0097     char **env;
0098     prte_job_t *jdata;
0099     prte_app_context_t *app;
0100     prte_proc_t *child;
0101     bool index_argv;
0102     prte_iof_base_io_conf_t opts;
0103     prte_odls_base_fork_local_proc_fn_t fork_local;
0104 } prte_odls_spawn_caddy_t;
0105 PMIX_CLASS_DECLARATION(prte_odls_spawn_caddy_t);
0106 
0107 /* define an object for starting local launch */
0108 typedef struct {
0109     pmix_object_t object;
0110     prte_event_t *ev;
0111     pmix_nspace_t job;
0112     prte_odls_base_fork_local_proc_fn_t fork_local;
0113     int retries;
0114 } prte_odls_launch_local_t;
0115 PRTE_EXPORT PMIX_CLASS_DECLARATION(prte_odls_launch_local_t);
0116 
0117 #define PRTE_ACTIVATE_LOCAL_LAUNCH(j, f)                           \
0118     do {                                                           \
0119         prte_odls_launch_local_t *ll;                              \
0120         ll = PMIX_NEW(prte_odls_launch_local_t);                   \
0121         PMIX_LOAD_NSPACE(ll->job, (j));                            \
0122         ll->fork_local = (f);                                      \
0123         prte_event_set(prte_event_base, ll->ev, -1, PRTE_EV_WRITE, \
0124                        prte_odls_base_default_launch_local, ll);   \
0125         prte_event_active(ll->ev, PRTE_EV_WRITE, 1);               \
0126     } while (0);
0127 
0128 PRTE_EXPORT void prte_odls_base_default_launch_local(int fd, short sd, void *cbdata);
0129 
0130 PRTE_EXPORT void prte_odls_base_default_wait_local_proc(int fd, short sd, void *cbdata);
0131 
0132 /* define a function type to signal a local proc */
0133 typedef int (*prte_odls_base_signal_local_fn_t)(pid_t pid, int signum);
0134 
0135 PRTE_EXPORT int
0136 prte_odls_base_default_signal_local_procs(const pmix_proc_t *proc, int32_t signal,
0137                                           prte_odls_base_signal_local_fn_t signal_local);
0138 
0139 /* define a function type for killing a local proc */
0140 typedef int (*prte_odls_base_kill_local_fn_t)(pid_t pid, int signum);
0141 
0142 /* define a function type to detect that a child died */
0143 typedef bool (*prte_odls_base_child_died_fn_t)(prte_proc_t *child);
0144 
0145 PRTE_EXPORT int prte_odls_base_default_kill_local_procs(pmix_pointer_array_t *procs,
0146                                                         prte_odls_base_kill_local_fn_t kill_local);
0147 
0148 PRTE_EXPORT int prte_odls_base_default_restart_proc(prte_proc_t *child,
0149                                                     prte_odls_base_fork_local_proc_fn_t fork_local);
0150 
0151 /*
0152  * Preload binary/files functions
0153  */
0154 PRTE_EXPORT int prte_odls_base_preload_files_app_context(prte_app_context_t *context);
0155 
0156 PRTE_EXPORT void prte_odls_base_start_threads(prte_job_t *jdata);
0157 
0158 PRTE_EXPORT void prte_odls_base_harvest_threads(void);
0159 
0160 #define PRTE_ODLS_SET_ERROR(ns, s, j)                                                   \
0161 do {                                                                                    \
0162     int _idx;                                                                           \
0163     prte_proc_t *_cld;                                                                  \
0164     unsigned int _j = (unsigned int)j;                                                  \
0165     for (_idx = 0; _idx < prte_local_children->size; _idx++) {                          \
0166         _cld = (prte_proc_t *) pmix_pointer_array_get_item(prte_local_children, _idx);  \
0167         if (NULL == _cld) {                                                             \
0168             continue;                                                                   \
0169         }                                                                               \
0170         if (PMIX_CHECK_NSPACE(ns, _cld->name.nspace) &&                                 \
0171             (UINT_MAX == _j || _j == _cld->app_idx)) {                                  \
0172             _cld->exit_code = s;                                                        \
0173             PRTE_ACTIVATE_PROC_STATE(&_cld->name, PRTE_PROC_STATE_FAILED_TO_LAUNCH);    \
0174         }                                                                               \
0175     }                                                                                   \
0176 } while(0)
0177 
0178 END_C_DECLS
0179 #endif