Main Page | Modules | Data Structures | File List | Data Fields | Globals

src/drmaa_impl.h

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 typedef struct drmaa_job_s drmaa_job_t;
00046 
00048 extern pthread_mutex_t drmaa_session_mutex;
00049 extern drmaa_session_t *drmaa_session;
00050 
00051 
00053 struct drmaa_session_s {
00054   int                   pbs_conn;    
00055   char                 *contact;     
00056   drmaa_job_template_t *jt_list;     
00058   drmaa_job_t         **job_hashtab; 
00062   int                   next_time_label;  
00063   pthread_mutex_t       conn_mutex;  
00064   pthread_mutex_t       jobs_mutex;  
00066 };
00067 
00069 struct drmaa_job_template_s {
00070   drmaa_session_t      *session; 
00071   drmaa_job_template_t *prev;    
00072   drmaa_job_template_t *next;    
00073   void                **attrib;  
00077   pthread_mutex_t       mutex;   
00078 };
00079 
00080 
00081 struct drmaa_attr_names_s  { char **list, **iter; };
00082 struct drmaa_attr_values_s { char **list, **iter; };
00083 struct drmaa_job_ids_s     { char **list, **iter; };
00084 
00085 
00086 typedef struct drmaa_submission_context_s drmaa_submission_context_t;
00087 
00088 enum{
00089   DRMAA_PLACEHOLDER_MASK_HD    = 1<<0,
00090   DRMAA_PLACEHOLDER_MASK_WD    = 1<<1,
00091   DRMAA_PLACEHOLDER_MASK_INCR  = 1<<2
00092 };
00093 
00094 struct drmaa_submission_context_s {
00095   const drmaa_job_template_t *jt;
00096   struct attropl *pbs_attribs;
00097   char *script_filename;
00098   char *home_directory;
00099   char *working_directory;
00100   char *bulk_incr_no;
00101 };
00102 
00103 
00106 int
00107 drmaa_create( drmaa_session_t **pc, const char *contact, char *errmsg, size_t errlen );
00108 
00109 int
00110 drmaa_destroy( drmaa_session_t *c, char *errmsg, size_t errlen );
00114 void
00115 drmaa_delete_async_job_template( drmaa_job_template_t *jt );
00116 
00117 
00118 
00119 int
00120 drmaa_impl_get_attribute_names(
00121     drmaa_attr_names_t **values,
00122     unsigned f_mask, unsigned flags,
00123     char *errmsg, size_t errlen
00124     );
00125 
00126 int
00127 drmaa_run_job_impl(
00128     char *job_id, size_t job_id_len,
00129     const drmaa_job_template_t *jt, int bulk_no,
00130     char *errmsg, size_t errlen
00131     );
00132 
00133 int
00134 drmaa_job_wait(
00135     const char *jobid, char *out_jobid, size_t out_jobid_size,
00136     int *stat, drmaa_attr_values_t **rusage,
00137     int dispose, time_t timeout_time,
00138     char *errmsg, size_t errlen
00139     );
00140 
00147 bool
00148 drmaa_check_empty_session( drmaa_session_t *c );
00149 
00150 
00151 
00152 int
00153 drmaa_create_submission_context(
00154     drmaa_submission_context_t **c,
00155     const drmaa_job_template_t *jt, int bulk_no,
00156     char *errmsg, size_t errlen );
00157 
00158 void
00159 drmaa_free_submission_context( drmaa_submission_context_t *c );
00160 
00161 int
00162 drmaa_set_job_std_attribs(
00163     drmaa_submission_context_t *c,
00164     char *errmsg, size_t errlen
00165     );
00166 
00167 int
00168 drmaa_create_job_script(
00169     drmaa_submission_context_t *c,
00170     char *errmsg, size_t errlen
00171     );
00172 
00173 int
00174 drmaa_set_job_files(
00175     drmaa_submission_context_t *c,
00176     char *errmsg, size_t errlen
00177     );
00178 
00179 int
00180 drmaa_set_file_staging(
00181     drmaa_submission_context_t *c,
00182     char *errmsg, size_t errlen
00183     );
00184 
00185 int
00186 drmaa_set_job_environment(
00187     drmaa_submission_context_t *c,
00188     char *errmsg, size_t errlen
00189     );
00190 
00191 char *
00192 drmaa_translate_staging( const char *stage );
00193 
00194 int
00195 drmaa_set_job_email_notication(
00196     drmaa_submission_context_t *c,
00197     char *errmsg, size_t errlen
00198     );
00199 
00200 int
00201 drmaa_set_job_submit_state(
00202     drmaa_submission_context_t *c,
00203     char *errmsg, size_t errlen
00204     );
00205 
00206 int
00207 drmaa_add_pbs_attr(
00208     drmaa_submission_context_t *c,
00209     int attr, char *value,
00210     unsigned set,
00211     char *errmsg, size_t errlen
00212     );
00213 
00214 int
00215 drmaa_write_tmpfile(
00216    char **filename, const char *content, size_t len,
00217    char *errmsg, size_t errlen
00218    );
00219 
00220 char *
00221 drmaa_explode( const char **vector, char glue );
00222 
00223 void
00224 drmaa_free_vector( char **vector );
00225 
00226 void
00227 drmaa_free_attropl( struct attropl *attr );
00228 
00229 char *
00230 drmaa_expand_placeholders(
00231     drmaa_submission_context_t *c, char *input, unsigned set );
00232 
00233 char *
00234 drmaa_replace( char *input, const char *placeholder, const char *value );
00235 
00236 
00237 #define GET_DRMAA_SESSION( session ) do{            \
00238   pthread_mutex_lock( &drmaa_session_mutex );       \
00239   if( drmaa_session == NULL )                       \
00240    {                                                \
00241     pthread_mutex_unlock( &drmaa_session_mutex );   \
00242     RAISE_DRMAA( DRMAA_ERRNO_NO_ACTIVE_SESSION );   \
00243    }                                                \
00244   session = drmaa_session;                          \
00245   pthread_mutex_unlock( &drmaa_session_mutex );     \
00246  }while(0)
00247 
00248 #define RELEASE_DRMAA_SESSION( session ) /* nothing */
00249 
00250 
00251 #endif /* __DRMAA_IMPL_H */
00252 

Generated on Fri Jan 25 14:38:53 2008 for torque by  doxygen 1.3.9.1