|
torque
2.5.12
|
00001 /* $Id: drmaa_impl.h,v 1.9 2006/09/08 18:18:08 ciesnik Exp $ */ 00002 /* 00003 * DRMAA library for Torque/PBS 00004 * Copyright (C) 2006 Poznan Supercomputing and Networking Center 00005 * DSP team <dsp-devel@hedera.man.poznan.pl> 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00022 #ifndef __DRMAA_IMPL_H 00023 #define __DRMAA_IMPL_H 00024 00025 #ifdef HAVE_CONFIG_H 00026 # include <pbs_config.h> 00027 #endif 00028 00029 #include <sys/types.h> 00030 00031 #ifdef HAVE_STDBOOL_H 00032 #include <stdbool.h> 00033 #endif 00034 00035 #include <time.h> 00036 00037 #include <pthread.h> 00038 #include "pbs_ifl.h" 00039 00040 #include <drmaa.h> 00041 #include <error.h> 00042 #include <compat.h> 00043 00044 typedef struct drmaa_session_s drmaa_session_t; 00045 00046 typedef struct drmaa_job_s drmaa_job_t; 00047 00049 extern pthread_mutex_t drmaa_session_mutex; 00050 extern drmaa_session_t *drmaa_session; 00051 00052 00055 struct drmaa_session_s 00056 { 00057 int pbs_conn; 00058 char *contact; 00059 drmaa_job_template_t *jt_list; 00061 drmaa_job_t **job_hashtab; 00065 int next_time_label; 00066 pthread_mutex_t conn_mutex; 00067 pthread_mutex_t jobs_mutex; 00069 }; 00070 00073 struct drmaa_job_template_s 00074 { 00075 drmaa_session_t *session; 00076 drmaa_job_template_t *prev; 00077 drmaa_job_template_t *next; 00078 void **attrib; 00082 pthread_mutex_t mutex; 00083 }; 00084 00085 00086 struct drmaa_attr_names_s 00087 { 00088 char **list, **iter; 00089 }; 00090 00091 struct drmaa_attr_values_s 00092 { 00093 char **list, **iter; 00094 }; 00095 00096 struct drmaa_job_ids_s 00097 { 00098 char **list, **iter; 00099 }; 00100 00101 00102 typedef struct drmaa_submission_context_s drmaa_submission_context_t; 00103 00104 enum 00105 { 00106 DRMAA_PLACEHOLDER_MASK_HD = 1 << 0, 00107 DRMAA_PLACEHOLDER_MASK_WD = 1 << 1, 00108 DRMAA_PLACEHOLDER_MASK_INCR = 1 << 2 00109 }; 00110 00111 struct drmaa_submission_context_s 00112 { 00113 const drmaa_job_template_t *jt; 00114 00115 struct attropl *pbs_attribs; 00116 char *script_filename; 00117 char *home_directory; 00118 char *working_directory; 00119 char *bulk_incr_no; 00120 }; 00121 00122 00125 int 00126 drmaa_create(drmaa_session_t **pc, const char *contact, char *errmsg, size_t errlen); 00127 00128 int 00129 drmaa_destroy(drmaa_session_t *c, char *errmsg, size_t errlen); 00133 void 00134 drmaa_delete_async_job_template(drmaa_job_template_t *jt); 00135 00136 00137 00138 int 00139 drmaa_impl_get_attribute_names( 00140 drmaa_attr_names_t **values, 00141 unsigned f_mask, unsigned flags, 00142 char *errmsg, size_t errlen 00143 ); 00144 00145 int 00146 drmaa_run_job_impl( 00147 char *job_id, size_t job_id_len, 00148 const drmaa_job_template_t *jt, int bulk_no, 00149 char *errmsg, size_t errlen 00150 ); 00151 00152 int 00153 drmaa_job_wait( 00154 const char *jobid, char *out_jobid, size_t out_jobid_size, 00155 int *stat, drmaa_attr_values_t **rusage, 00156 int dispose, time_t timeout_time, 00157 char *errmsg, size_t errlen 00158 ); 00159 00166 bool 00167 drmaa_check_empty_session(drmaa_session_t *c); 00168 00169 00170 00171 int 00172 drmaa_create_submission_context( 00173 drmaa_submission_context_t **c, 00174 const drmaa_job_template_t *jt, int bulk_no, 00175 char *errmsg, size_t errlen); 00176 00177 void 00178 drmaa_free_submission_context(drmaa_submission_context_t *c); 00179 00180 int 00181 drmaa_set_job_std_attribs( 00182 drmaa_submission_context_t *c, 00183 char *errmsg, size_t errlen 00184 ); 00185 00186 int 00187 drmaa_create_job_script( 00188 drmaa_submission_context_t *c, 00189 char *errmsg, size_t errlen 00190 ); 00191 00192 int 00193 drmaa_set_job_files( 00194 drmaa_submission_context_t *c, 00195 char *errmsg, size_t errlen 00196 ); 00197 00198 int 00199 drmaa_set_file_staging( 00200 drmaa_submission_context_t *c, 00201 char *errmsg, size_t errlen 00202 ); 00203 00204 int 00205 drmaa_set_job_environment( 00206 drmaa_submission_context_t *c, 00207 char *errmsg, size_t errlen 00208 ); 00209 00210 char * 00211 drmaa_translate_staging(const char *stage); 00212 00213 int 00214 drmaa_set_job_email_notication( 00215 drmaa_submission_context_t *c, 00216 char *errmsg, size_t errlen 00217 ); 00218 00219 int 00220 drmaa_set_job_submit_state( 00221 drmaa_submission_context_t *c, 00222 char *errmsg, size_t errlen 00223 ); 00224 00225 int 00226 drmaa_add_pbs_attr( 00227 drmaa_submission_context_t *c, 00228 int attr, char *value, 00229 unsigned set, 00230 char *errmsg, size_t errlen 00231 ); 00232 00233 int 00234 drmaa_write_tmpfile( 00235 char **filename, const char *content, size_t len, 00236 char *errmsg, size_t errlen 00237 ); 00238 00239 char * 00240 drmaa_explode(const char **vector, char glue); 00241 00242 void 00243 drmaa_free_vector(char **vector); 00244 00245 void 00246 drmaa_free_attropl(struct attropl *attr); 00247 00248 char * 00249 drmaa_expand_placeholders( 00250 drmaa_submission_context_t *c, char *input, unsigned set); 00251 00252 char * 00253 drmaa_replace(char *input, const char *placeholder, const char *value); 00254 00255 00256 #define GET_DRMAA_SESSION( session ) do{ \ 00257 pthread_mutex_lock( &drmaa_session_mutex ); \ 00258 if( drmaa_session == NULL ) \ 00259 { \ 00260 pthread_mutex_unlock( &drmaa_session_mutex ); \ 00261 RAISE_DRMAA( DRMAA_ERRNO_NO_ACTIVE_SESSION ); \ 00262 } \ 00263 session = drmaa_session; \ 00264 pthread_mutex_unlock( &drmaa_session_mutex ); \ 00265 }while(0) 00266 00267 #define RELEASE_DRMAA_SESSION( session ) /* nothing */ 00268 00269 00270 #endif /* __DRMAA_IMPL_H */ 00271
1.8.0