1 /*****************************************************************************\ 2 * launch.h - Define job launch plugin functions. 3 ***************************************************************************** 4 * Copyright (C) 2012 SchedMD LLC 5 * Written by Danny Auble <da@schedmd.com> 6 * 7 * This file is part of Slurm, a resource management program. 8 * For details, see <https://slurm.schedmd.com/>. 9 * Please also read the included file: DISCLAIMER. 10 * 11 * Slurm is free software; you can redistribute it and/or modify it under 12 * the terms of the GNU General Public License as published by the Free 13 * Software Foundation; either version 2 of the License, or (at your option) 14 * any later version. 15 * 16 * In addition, as a special exception, the copyright holders give permission 17 * to link the code of portions of this program with the OpenSSL library under 18 * certain conditions as described in each individual source file, and 19 * distribute linked combinations including the two. You must obey the GNU 20 * General Public License in all respects for all of the code used other than 21 * OpenSSL. If you modify file(s) with this exception, you may extend this 22 * exception to your version of the file(s), but you are not obligated to do 23 * so. If you do not wish to do so, delete this exception statement from your 24 * version. If you delete this exception statement from all source files in 25 * the program, then also delete it here. 26 * 27 * Slurm is distributed in the hope that it will be useful, but WITHOUT ANY 28 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 29 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 30 * details. 31 * 32 * You should have received a copy of the GNU General Public License along 33 * with Slurm; if not, write to the Free Software Foundation, Inc., 34 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 35 \*****************************************************************************/ 36 37 #ifndef _LAUNCH_H 38 #define _LAUNCH_H 39 40 #include "slurm/slurm.h" 41 #include "slurm/slurm_errno.h" 42 43 #include "src/common/xstring.h" 44 45 #include "src/srun/libsrun/srun_job.h" 46 #include "src/srun/libsrun/opt.h" 47 #include "src/srun/libsrun/debugger.h" 48 49 /* 50 * launch_common_get_slurm_step_layout() gets the slurm job step layout. 51 * 52 * IN job - the job step layout to get. 53 * 54 * RETURN SLURM_SUCCESS on success || SLURM_ERROR else wise 55 */ 56 extern slurm_step_layout_t *launch_common_get_slurm_step_layout( 57 srun_job_t *job); 58 59 /* 60 * launch_common_create_job_step() creates the job step with the given info. 61 * 62 * IN job - job to be created into a job step 63 * IN use_all_cpus - the choice to use all the cpus. 64 * IN signal_function - function that handles the signals coming in. 65 * IN destroy_job - pointer to a global flag signifying if the job was 66 * canceled while allocating. 67 * 68 * RETURN SLURM_SUCCESS on success || SLURM_ERROR else wise 69 */ 70 extern int launch_common_create_job_step(srun_job_t *job, bool use_all_cpus, 71 void (*signal_function)(int), 72 sig_atomic_t *destroy_job, 73 slurm_opt_t *opt_local); 74 75 /* 76 * launch_common_set_stdio_fds() sets the stdio_fds to given info. 77 * 78 * IN job - the job that is set. 79 * IN cio_fds - filling in io descriptors. 80 */ 81 extern void launch_common_set_stdio_fds(srun_job_t *job, 82 slurm_step_io_fds_t *cio_fds, 83 slurm_opt_t *opt_local); 84 85 /* 86 * init() is called when the plugin is loaded, before any other functions 87 * are called. Put global initialization here. 88 */ 89 extern int launch_init(void); 90 91 /* 92 * fini() is called when the plugin is removed. Clear any allocated 93 * storage here. 94 */ 95 extern int launch_fini(void); 96 97 /* 98 * launch_g_setup_srun_opt() is called when the plugin needs the srun 99 * operation needs to be set up. 100 * 101 * IN rest - extra parameters on the command line not processed by srun 102 * IN opt_local - options used for step creation 103 */ 104 extern int launch_g_setup_srun_opt(char **rest, slurm_opt_t *opt_local); 105 106 /* 107 * launch_g_handle_multi_prog_verify() is called to verify a 108 * multi-prog file if verifying needs to be done. 109 * 110 * IN command_pos - to be used with global opt variable to tell which 111 * spot the command is in opt.argv. 112 * IN opt_local - options used for step creation 113 * 114 * RET 0 if not handled, 1 if handled 115 */ 116 extern int launch_g_handle_multi_prog_verify(int command_pos, slurm_opt_t *opt_local); 117 118 /* 119 * launch_g_create_job_step() creates the job step. 120 * 121 * IN/OUT job - the job to be created into a job step. 122 * IN use_all_cpus - the choice to use all the cpus. 123 * IN signal_function - function that handles the signals coming in. 124 * IN destroy_job - pointer to a global flag signifying if the job was 125 * canceled while allocating. 126 * IN opt_local - options used for step creation 127 * 128 * RETURN SLURM_SUCCESS on success || SLURM_ERROR else wise 129 */ 130 extern int launch_g_create_job_step(srun_job_t *job, bool use_all_cpus, 131 void (*signal_function)(int), 132 sig_atomic_t *destroy_job, 133 slurm_opt_t *opt_local); 134 135 /* 136 * launch_g_step_launch() is called to launch the job step that 137 * was created. 138 * 139 * IN/OUT job - the job needing to be launched 140 * IN cio_fds - filled in io descriptors. 141 * IN/OUT global_rc - srun global return code. 142 * IN step_callbacks - callbacks for various points in the life of the step. 143 * IN opt_local - options used for step creation 144 * RETURN SLURM_SUCCESS on success || SLURM_ERROR else wise 145 */ 146 extern int launch_g_step_launch(srun_job_t *job, slurm_step_io_fds_t *cio_fds, 147 uint32_t *global_rc, 148 slurm_step_launch_callbacks_t *step_callbacks, 149 slurm_opt_t *opt_local); 150 151 /* 152 * launch_g_step_wait() is called to wait for the job step to be finished. 153 * 154 * IN/OUT job - the job waiting to finish. 155 * IN got_alloc - if the resource allocation was created inside srun 156 * IN opt_local - options used for step creation 157 * 158 * RETURN SLURM_SUCCESS on success || SLURM_ERROR else wise 159 */ 160 extern int launch_g_step_wait(srun_job_t *job, bool got_alloc, 161 slurm_opt_t *opt_local); 162 163 /* 164 * launch_g_step_terminate() is called to end the job step. 165 * 166 * RETURN SLURM_SUCCESS on success || SLURM_ERROR else wise 167 */ 168 extern int launch_g_step_terminate(void); 169 170 /* 171 * launch_g_print_status() displays the status of the job step. 172 */ 173 extern void launch_g_print_status(void); 174 175 /* 176 * launch_g_fwd_signal() send a forward signal to an underlining task. 177 * 178 * IN signal - the signal to forward to the underlying tasks. 179 */ 180 extern void launch_g_fwd_signal(int signal); 181 182 #endif /* _LAUNCH_H */ 183