Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 09:06:26

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-2025 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     char *exec_agent;
0060 } prte_odls_globals_t;
0061 
0062 PRTE_EXPORT extern prte_odls_globals_t prte_odls_globals;
0063 
0064 /*
0065  * MCA framework
0066  */
0067 PRTE_EXPORT extern pmix_mca_base_framework_t prte_odls_base_framework;
0068 /*
0069  * Select an available component.
0070  */
0071 PRTE_EXPORT int prte_odls_base_select(void);
0072 
0073 /*
0074  * Default functions that are common to most environments - can
0075  * be overridden by specific environments if they need something
0076  * different (e.g., bproc)
0077  */
0078 PRTE_EXPORT int prte_odls_base_default_get_add_procs_data(pmix_data_buffer_t *data,
0079                                                           pmix_nspace_t job);
0080 
0081 PRTE_EXPORT int prte_odls_base_default_construct_child_list(pmix_data_buffer_t *data,
0082                                                             pmix_nspace_t *job);
0083 
0084 PRTE_EXPORT void prte_odls_base_spawn_proc(int fd, short sd, void *cbdata);
0085 
0086 /* define a function that will fork a local proc */
0087 typedef int (*prte_odls_base_fork_local_proc_fn_t)(void *cd);
0088 
0089 /* define an object for fork/exec the local proc */
0090 typedef struct {
0091     pmix_object_t super;
0092     prte_event_t ev;
0093     char *cmd;
0094     char *wdir;
0095     char **argv;
0096     char **env;
0097     prte_job_t *jdata;
0098     prte_app_context_t *app;
0099     prte_proc_t *child;
0100     bool index_argv;
0101     prte_iof_base_io_conf_t opts;
0102     prte_odls_base_fork_local_proc_fn_t fork_local;
0103 } prte_odls_spawn_caddy_t;
0104 PMIX_CLASS_DECLARATION(prte_odls_spawn_caddy_t);
0105 
0106 /* define an object for starting local launch */
0107 typedef struct {
0108     pmix_object_t object;
0109     prte_event_t *ev;
0110     pmix_nspace_t job;
0111     prte_odls_base_fork_local_proc_fn_t fork_local;
0112     int retries;
0113 } prte_odls_launch_local_t;
0114 PRTE_EXPORT PMIX_CLASS_DECLARATION(prte_odls_launch_local_t);
0115 
0116 #define PRTE_ACTIVATE_LOCAL_LAUNCH(j, f)                           \
0117     do {                                                           \
0118         prte_odls_launch_local_t *ll;                              \
0119         ll = PMIX_NEW(prte_odls_launch_local_t);                   \
0120         PMIX_LOAD_NSPACE(ll->job, (j));                            \
0121         ll->fork_local = (f);                                      \
0122         prte_event_set(prte_event_base, ll->ev, -1, PRTE_EV_WRITE, \
0123                        prte_odls_base_default_launch_local, ll);   \
0124         prte_event_active(ll->ev, PRTE_EV_WRITE, 1);               \
0125     } while (0);
0126 
0127 PRTE_EXPORT void prte_odls_base_default_launch_local(int fd, short sd, void *cbdata);
0128 
0129 PRTE_EXPORT void prte_odls_base_default_wait_local_proc(int fd, short sd, void *cbdata);
0130 
0131 /* define a function type to signal a local proc */
0132 typedef int (*prte_odls_base_signal_local_fn_t)(pid_t pid, int signum);
0133 
0134 PRTE_EXPORT int
0135 prte_odls_base_default_signal_local_procs(const pmix_proc_t *proc, int32_t signal,
0136                                           prte_odls_base_signal_local_fn_t signal_local);
0137 
0138 /* define a function type for killing a local proc */
0139 typedef int (*prte_odls_base_kill_local_fn_t)(pid_t pid, int signum);
0140 
0141 /* define a function type to detect that a child died */
0142 typedef bool (*prte_odls_base_child_died_fn_t)(prte_proc_t *child);
0143 
0144 PRTE_EXPORT int prte_odls_base_default_kill_local_procs(pmix_pointer_array_t *procs,
0145                                                         prte_odls_base_kill_local_fn_t kill_local);
0146 
0147 PRTE_EXPORT int prte_odls_base_default_restart_proc(prte_proc_t *child,
0148                                                     prte_odls_base_fork_local_proc_fn_t fork_local);
0149 
0150 /*
0151  * Preload binary/files functions
0152  */
0153 PRTE_EXPORT int prte_odls_base_preload_files_app_context(prte_app_context_t *context);
0154 
0155 PRTE_EXPORT void prte_odls_base_start_threads(prte_job_t *jdata);
0156 
0157 PRTE_EXPORT void prte_odls_base_harvest_threads(void);
0158 
0159 /* Binding support */
0160 PRTE_EXPORT void prte_odls_base_set(prte_odls_spawn_caddy_t *cd, int write_fd);
0161 
0162 
0163 #define PRTE_ODLS_SET_ERROR(ns, s, j)                                                   \
0164 do {                                                                                    \
0165     int _idx;                                                                           \
0166     prte_proc_t *_cld;                                                                  \
0167     unsigned int _j = (unsigned int)j;                                                  \
0168     for (_idx = 0; _idx < prte_local_children->size; _idx++) {                          \
0169         _cld = (prte_proc_t *) pmix_pointer_array_get_item(prte_local_children, _idx);  \
0170         if (NULL == _cld) {                                                             \
0171             continue;                                                                   \
0172         }                                                                               \
0173         if (PMIX_CHECK_NSPACE(ns, _cld->name.nspace) &&                                 \
0174             (UINT_MAX == _j || _j == _cld->app_idx)) {                                  \
0175             _cld->exit_code = s;                                                        \
0176             PRTE_ACTIVATE_PROC_STATE(&_cld->name, PRTE_PROC_STATE_FAILED_TO_LAUNCH);    \
0177         }                                                                               \
0178     }                                                                                   \
0179 } while(0)
0180 
0181 END_C_DECLS
0182 #endif