torque  4.1.5.1
 All Data Structures Files Functions Variables Groups
drmaa_impl.h
1 /* $Id: drmaa_impl.h,v 1.9 2006/09/08 18:18:08 ciesnik Exp $ */
2 /*
3  * DRMAA library for Torque/PBS
4  * Copyright (C) 2006 Poznan Supercomputing and Networking Center
5  * DSP team <dsp-devel@hedera.man.poznan.pl>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef __DRMAA_IMPL_H
23 #define __DRMAA_IMPL_H
24 
25 #ifdef HAVE_CONFIG_H
26 # include <pbs_config.h>
27 #endif
28 
29 #include <sys/types.h>
30 
31 #ifdef HAVE_STDBOOL_H
32 #include <stdbool.h>
33 #endif
34 
35 #include <time.h>
36 
37 #include <pthread.h>
38 #include "pbs_ifl.h"
39 
40 #include <drmaa.h>
41 #include <error.h>
42 #include <compat.h>
43 
44 typedef struct drmaa_session_s drmaa_session_t;
45 
46 typedef struct drmaa_job_s drmaa_job_t;
47 
49 extern pthread_mutex_t drmaa_session_mutex;
50 extern drmaa_session_t *drmaa_session;
51 
52 
56  {
57  int pbs_conn;
58  char *contact;
66  pthread_mutex_t conn_mutex;
67  pthread_mutex_t jobs_mutex;
69  };
70 
74  {
78  void **attrib;
82  pthread_mutex_t mutex;
83  };
84 
85 
87  {
88  char **list, **iter;
89  };
90 
92  {
93  char **list, **iter;
94  };
95 
97  {
98  char **list, **iter;
99  };
100 
101 
103 
104 enum
105  {
106  DRMAA_PLACEHOLDER_MASK_HD = 1 << 0,
107  DRMAA_PLACEHOLDER_MASK_WD = 1 << 1,
108  DRMAA_PLACEHOLDER_MASK_INCR = 1 << 2
109  };
110 
112  {
113  const drmaa_job_template_t *jt;
114 
115  struct attropl *pbs_attribs;
116  char *script_filename;
117  char *home_directory;
118  char *working_directory;
119  char *bulk_incr_no;
120  };
121 
122 
125 int
126 drmaa_create(drmaa_session_t **pc, const char *contact, char *errmsg, size_t errlen);
127 
128 int
129 drmaa_destroy(drmaa_session_t *c, char *errmsg, size_t errlen);
133 void
134 drmaa_delete_async_job_template(drmaa_job_template_t *jt);
135 
136 
137 
138 int
139 drmaa_impl_get_attribute_names(
140  drmaa_attr_names_t **values,
141  unsigned f_mask, unsigned flags,
142  char *errmsg, size_t errlen
143 );
144 
145 int
146 drmaa_run_job_impl(
147  char *job_id, size_t job_id_len,
148  const drmaa_job_template_t *jt, int bulk_no,
149  char *errmsg, size_t errlen
150 );
151 
152 int
153 drmaa_job_wait(
154  const char *jobid, char *out_jobid, size_t out_jobid_size,
155  int *stat, drmaa_attr_values_t **rusage,
156  int dispose, time_t timeout_time,
157  char *errmsg, size_t errlen
158 );
159 
166 bool
167 drmaa_check_empty_session(drmaa_session_t *c);
168 
169 
170 
171 int
172 drmaa_create_submission_context(
174  const drmaa_job_template_t *jt, int bulk_no,
175  char *errmsg, size_t errlen);
176 
177 void
178 drmaa_free_submission_context(drmaa_submission_context_t *c);
179 
180 int
181 drmaa_set_job_std_attribs(
183  char *errmsg, size_t errlen
184 );
185 
186 int
187 drmaa_create_job_script(
189  char *errmsg, size_t errlen
190 );
191 
192 int
193 drmaa_set_job_files(
195  char *errmsg, size_t errlen
196 );
197 
198 int
199 drmaa_set_file_staging(
201  char *errmsg, size_t errlen
202 );
203 
204 int
205 drmaa_set_job_environment(
207  char *errmsg, size_t errlen
208 );
209 
210 char *
211 drmaa_translate_staging(const char *stage);
212 
213 int
214 drmaa_set_job_email_notication(
216  char *errmsg, size_t errlen
217 );
218 
219 int
220 drmaa_set_job_submit_state(
222  char *errmsg, size_t errlen
223 );
224 
225 int
226 drmaa_add_pbs_attr(
228  int attr, char *value,
229  unsigned set,
230  char *errmsg, size_t errlen
231 );
232 
233 int
234 drmaa_write_tmpfile(
235  char **filename, const char *content, size_t len,
236  char *errmsg, size_t errlen
237 );
238 
239 char *
240 drmaa_explode(const char **vector, char glue);
241 
242 void
243 drmaa_free_vector(char **vector);
244 
245 void
246 drmaa_free_attropl(struct attropl *attr);
247 
248 char *
249 drmaa_expand_placeholders(
250  drmaa_submission_context_t *c, char *input, unsigned set);
251 
252 char *
253 drmaa_replace(char *input, const char *placeholder, const char *value);
254 
255 
256 #define GET_DRMAA_SESSION( session ) do{ \
257  pthread_mutex_lock( &drmaa_session_mutex ); \
258  if( drmaa_session == NULL ) \
259  { \
260  pthread_mutex_unlock( &drmaa_session_mutex ); \
261  RAISE_DRMAA( DRMAA_ERRNO_NO_ACTIVE_SESSION ); \
262  } \
263  session = drmaa_session; \
264  pthread_mutex_unlock( &drmaa_session_mutex ); \
265  }while(0)
266 
267 #define RELEASE_DRMAA_SESSION( session ) /* nothing */
268 
269 
270 #endif /* __DRMAA_IMPL_H */
271