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

Generated on Fri Sep 8 20:19:21 2006 for DRMAA 1.0 library for Torque/PBS by  doxygen 1.4.4