Compare commits

...

12 Commits

Author SHA1 Message Date
432df69591 Merge branch 'develop' 2024-08-27 16:40:17 +02:00
0a08d83c90 add vscode settings.json 2024-08-27 16:36:46 +02:00
3bf874cce1 Add OpenMPI tools documentation to README
The commit adds a new section to the README file, providing information about the OpenMPI tools available in the gridengine setup. It explains where to find the scripts and executables, how to build them using source code, and provides instructions for installation. The README also mentions reading the copyright and usage information in the source code's README file.
2024-08-27 16:36:13 +02:00
f038f8ce5c adding source and scripts for ompi testing scripts
provided scripts:
* ompi_connectivity.sh
* ompi_hello.sh
* ompi_ring.sh
2024-08-26 18:48:03 +02:00
c23bdece04 adding script to work.sh in examples/jobs 2024-08-26 18:20:21 +02:00
46b847aff9 adding original examples 2024-08-26 18:03:25 +02:00
a4f6456292 add local config in folder spool 2024-08-26 17:56:40 +02:00
81897cf285 add flex-grid folder for flexlm license manager accounting 2024-08-26 17:54:28 +02:00
d26631afd2 update local folder to match files acctually used 2024-08-26 17:52:43 +02:00
cac9c91222 move everything to local folder 2024-08-26 17:34:54 +02:00
f92678d3f5 Merge branch 'develop' 2024-08-26 17:29:16 +02:00
add7211f76 updated prolog.d/10-GPU_allocate.sh 2024-08-13 14:32:19 +02:00
281 changed files with 11905 additions and 198 deletions

35
.gitignore vendored
View File

@ -5,7 +5,8 @@
.LSOverride
# Icon must end with two \r
Icon
Icon
# Thumbnails
._*
@ -37,3 +38,35 @@ Temporary Items
# Local History for Visual Studio Code
.history/
# local files
spool/qmaster/jobs
spool/qmaster/job_scripts
spool/qmaster/messages*
spool/qmaster/qmaster.pid
spool/qmaster/heartbeat
spool/qmaster/arseqnum
spool/qmaster/advance_reservations
spool/qmaster/jobseqnum
spool/qmaster/zombies
spool/gaia
spool/minos11
spool/minos12
spool/minos13
spool/minos14
spool/minos15
spool/minos26
spool/minos27
spool/qmaster/users
local/examples/src/OpenMPI/connectivity_c
local/examples/src/OpenMPI/hello_c
local/examples/src/OpenMPI/hello_cxx
local/examples/src/OpenMPI/hello_f77
local/examples/src/OpenMPI/hello_f90
local/examples/src/OpenMPI/ring_c
local/examples/src/OpenMPI/ring_cxx
local/examples/src/OpenMPI/ring_f77
local/examples/src/OpenMPI/ring_f90
local/examples/jobsbin/ompi_connectivity_*
local/examples/jobsbin/ompi_hello_*
local/examples/jobsbin/ompi_ring_*

5
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"cSpell.words": [
"gridengine"
]
}

View File

@ -1,3 +1,7 @@
# gridengine
Scripts to manage the gridengine software
Scripts and configuration files to manage the gridengine software running int the Geophysics cluster.
## OpenMPI tools
The OpenMPI scripts to test the OpenMPI functionality of the gridengine setup are located in the folder `local/examples/jobs`. These scripts require the executables binaries in the folder `local/examples/jobsbin`. They can be build using the source code in `local/examples/src` with `make`. The script `install.sh` can be used to install the binaries in the `jobsbin` folder. Read the file `README` of the source code for the copyright of the code and its usage.

211
examples/drmaa/example.c Executable file
View File

@ -0,0 +1,211 @@
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* the Sun Industry Standards Source License Version 1.2
*
* Sun Microsystems Inc., March, 2001
*
*
* Sun Industry Standards Source License Version 1.2
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.2 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2001 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
************************************************************************/
/*___INFO__MARK_END__*/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "drmaa.h"
#define JOB_CHUNK 8
#define NBULKS 3
static drmaa_job_template_t *create_job_template(const char *job_path, int seconds, int as_bulk_job);
int main(int argc, char *argv[])
{
char diagnosis[DRMAA_ERROR_STRING_BUFFER];
const char *all_jobids[NBULKS*JOB_CHUNK + JOB_CHUNK+1];
char jobid[100];
int drmaa_errno, i, pos = 0;
const char *job_path;
drmaa_job_template_t *jt;
if (argc<2) {
fprintf(stderr, "usage: example <path-to-job>\n");
return 1;
}
job_path = argv[1];
if (drmaa_init(NULL, diagnosis, sizeof(diagnosis)-1) != DRMAA_ERRNO_SUCCESS) {
fprintf(stderr, "drmaa_init() failed: %s\n", diagnosis);
return 1;
}
/*
* submit some bulk jobs
*/
if (!(jt = create_job_template(job_path, 5, 1))) {
fprintf(stderr, "create_job_template() failed\n");
return 1;
}
for (i=0; i<NBULKS; i++) {
drmaa_job_ids_t *jobids;
int j;
while ((drmaa_errno=drmaa_run_bulk_jobs(&jobids, jt, 1, JOB_CHUNK, 1, diagnosis,
sizeof(diagnosis)-1))==DRMAA_ERRNO_DRM_COMMUNICATION_FAILURE) {
fprintf(stderr, "drmaa_run_bulk_jobs() failed - retry: %s %s\n", diagnosis, drmaa_strerror(drmaa_errno));
sleep(1);
}
if (drmaa_errno != DRMAA_ERRNO_SUCCESS) {
fprintf(stderr, "drmaa_run_bulk_jobs() failed: %s %s\n", diagnosis, drmaa_strerror(drmaa_errno));
return 1;
}
printf("submitted bulk job with jobids:\n");
for (j=0; j<JOB_CHUNK; j++) {
drmaa_get_next_job_id(jobids, jobid, sizeof(jobid)-1);
all_jobids[pos++] = strdup(jobid);
printf("\t \"%s\"\n", jobid);
}
drmaa_release_job_ids(jobids);
}
drmaa_delete_job_template(jt, NULL, 0);
/*
* submit some sequential jobs
*/
if (!(jt = create_job_template(job_path, 5, 0))) {
fprintf(stderr, "create_sleeper_job_template() failed\n");
return 1;
}
for (i=0; i<JOB_CHUNK; i++) {
while ((drmaa_errno=drmaa_run_job(jobid, sizeof(jobid)-1, jt, diagnosis,
sizeof(diagnosis)-1)) == DRMAA_ERRNO_DRM_COMMUNICATION_FAILURE) {
fprintf(stderr, "drmaa_run_job() failed - retry: %s\n", diagnosis);
sleep(1);
}
if (drmaa_errno != DRMAA_ERRNO_SUCCESS) {
fprintf(stderr, "drmaa_run_job() failed: %s\n", diagnosis);
return 1;
}
printf("\t \"%s\"\n", jobid);
all_jobids[pos++] = strdup(jobid);
}
/* set string array end mark */
all_jobids[pos] = NULL;
drmaa_delete_job_template(jt, NULL, 0);
/*
* synchronize with all jobs
*/
drmaa_errno = drmaa_synchronize(all_jobids, DRMAA_TIMEOUT_WAIT_FOREVER, 0, diagnosis, sizeof(diagnosis)-1);
if (drmaa_errno != DRMAA_ERRNO_SUCCESS) {
fprintf(stderr, "drmaa_synchronize(DRMAA_JOB_IDS_SESSION_ALL, dispose) failed: %s\n", diagnosis);
return 1;
}
printf("synchronized with all jobs\n");
/*
* wait all those jobs
*/
for (pos=0; pos<NBULKS*JOB_CHUNK + JOB_CHUNK; pos++) {
int stat;
int aborted, exited, exit_status, signaled;
drmaa_errno = drmaa_wait(all_jobids[pos], jobid, sizeof(jobid)-1,
&stat, DRMAA_TIMEOUT_WAIT_FOREVER, NULL, diagnosis, sizeof(diagnosis)-1);
if (drmaa_errno != DRMAA_ERRNO_SUCCESS) {
fprintf(stderr, "drmaa_wait(%s) failed: %s\n", all_jobids[pos], diagnosis);
return 1;
}
/*
* report how job finished
*/
drmaa_wifaborted(&aborted, stat, NULL, 0);
if (aborted)
printf("job \"%s\" never ran\n", all_jobids[pos]);
else {
drmaa_wifexited(&exited, stat, NULL, 0);
if (exited) {
drmaa_wexitstatus(&exit_status, stat, NULL, 0);
printf("job \"%s\" finished regularly with exit status %d\n",
all_jobids[pos], exit_status);
} else {
drmaa_wifsignaled(&signaled, stat, NULL, 0);
if (signaled) {
char termsig[DRMAA_SIGNAL_BUFFER+1];
drmaa_wtermsig(termsig, DRMAA_SIGNAL_BUFFER, stat, NULL, 0);
printf("job \"%s\" finished due to signal %s\n",
all_jobids[pos], termsig);
} else
printf("job \"%s\" finished with unclear conditions\n",
all_jobids[pos]);
}
}
}
if (drmaa_exit(diagnosis, sizeof(diagnosis)-1) != DRMAA_ERRNO_SUCCESS) {
fprintf(stderr, "drmaa_exit() failed: %s\n", diagnosis);
return 1;
}
return 0;
}
static drmaa_job_template_t *create_job_template(const char *job_path, int seconds, int as_bulk_job)
{
const char *job_argv[2];
drmaa_job_template_t *jt = NULL;
char buffer[100];
if (drmaa_allocate_job_template(&jt, NULL, 0)!=DRMAA_ERRNO_SUCCESS)
return NULL;
/* run in users home directory */
drmaa_set_attribute(jt, DRMAA_WD, DRMAA_PLACEHOLDER_HD, NULL, 0);
/* the job to be run */
drmaa_set_attribute(jt, DRMAA_REMOTE_COMMAND, job_path, NULL, 0);
/* the job's arguments */
sprintf(buffer, "%d", seconds);
job_argv[0] = buffer;
job_argv[1] = NULL;
drmaa_set_vector_attribute(jt, DRMAA_V_ARGV, job_argv, NULL, 0);
/* join output/error file */
drmaa_set_attribute(jt, DRMAA_JOIN_FILES, "y", NULL, 0);
/* path for output */
if (!as_bulk_job)
drmaa_set_attribute(jt, DRMAA_OUTPUT_PATH, ":"DRMAA_PLACEHOLDER_HD"/DRMAA_JOB", NULL, 0);
else
drmaa_set_attribute(jt, DRMAA_OUTPUT_PATH, ":"DRMAA_PLACEHOLDER_HD"/DRMAA_JOB."DRMAA_PLACEHOLDER_INCR, NULL, 0);
return jt;
}

56
examples/drmaa/howto1.c Executable file
View File

@ -0,0 +1,56 @@
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* the Sun Industry Standards Source License Version 1.2
*
* Sun Microsystems Inc., March, 2001
*
*
* Sun Industry Standards Source License Version 1.2
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.2 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2001 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
************************************************************************/
/*___INFO__MARK_END__*/
#include <stdio.h>
#include "drmaa.h"
int main (int argc, char **argv) {
char error[DRMAA_ERROR_STRING_BUFFER];
int errnum = 0;
errnum = drmaa_init (NULL, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not initialize the DRMAA library: %s\n", error);
return 1;
}
printf ("DRMAA library was started successfully\n");
errnum = drmaa_exit (error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not shut down the DRMAA library: %s\n", error);
return 1;
}
return 0;
}

81
examples/drmaa/howto1_1.c Executable file
View File

@ -0,0 +1,81 @@
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* the Sun Industry Standards Source License Version 1.2
*
* Sun Microsystems Inc., March, 2001
*
*
* Sun Industry Standards Source License Version 1.2
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.2 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2001 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
************************************************************************/
/*___INFO__MARK_END__*/
#include <stdio.h>
#include "drmaa.h"
int main (int argc, char **argv) {
char error[DRMAA_ERROR_STRING_BUFFER];
int errnum = 0;
char contact[DRMAA_CONTACT_BUFFER];
errnum = drmaa_init (NULL, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not initialize the DRMAA library: %s\n", error);
return 1;
}
printf ("DRMAA library was started successfully\n");
errnum = drmaa_get_contact (contact, DRMAA_CONTACT_BUFFER, error,
DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not get the contact string: %s\n", error);
return 1;
}
errnum = drmaa_exit (error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not shut down the DRMAA library: %s\n", error);
return 1;
}
errnum = drmaa_init (contact, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not reinitialize the DRMAA library: %s\n", error);
return 1;
}
printf ("DRMAA library was restarted successfully\n");
errnum = drmaa_exit (error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not shut down the DRMAA library: %s\n", error);
return 1;
}
return 0;
}

100
examples/drmaa/howto2.c Executable file
View File

@ -0,0 +1,100 @@
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* the Sun Industry Standards Source License Version 1.2
*
* Sun Microsystems Inc., March, 2001
*
*
* Sun Industry Standards Source License Version 1.2
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.2 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2001 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
************************************************************************/
/*___INFO__MARK_END__*/
#include <stdio.h>
#include "drmaa.h"
int main (int argc, char **argv) {
char error[DRMAA_ERROR_STRING_BUFFER];
int errnum = 0;
drmaa_job_template_t *jt = NULL;
errnum = drmaa_init (NULL, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not initialize the DRMAA library: %s\n", error);
return 1;
}
errnum = drmaa_allocate_job_template (&jt, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not create job template: %s\n", error);
}
else {
errnum = drmaa_set_attribute (jt, DRMAA_REMOTE_COMMAND, "sleeper.sh",
error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not set attribute \"%s\": %s\n",
DRMAA_REMOTE_COMMAND, error);
}
else {
const char *args[2] = {"5", NULL};
errnum = drmaa_set_vector_attribute (jt, DRMAA_V_ARGV, args, error,
DRMAA_ERROR_STRING_BUFFER);
}
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not set attribute \"%s\": %s\n",
DRMAA_REMOTE_COMMAND, error);
}
else {
char jobid[DRMAA_JOBNAME_BUFFER];
errnum = drmaa_run_job (jobid, DRMAA_JOBNAME_BUFFER, jt, error,
DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not submit job: %s\n", error);
}
else {
printf ("Your job has been submitted with id %s\n", jobid);
}
} /* else */
errnum = drmaa_delete_job_template (jt, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not delete job template: %s\n", error);
}
} /* else */
errnum = drmaa_exit (error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not shut down the DRMAA library: %s\n", error);
return 1;
}
return 0;
}

105
examples/drmaa/howto2_1.c Executable file
View File

@ -0,0 +1,105 @@
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* the Sun Industry Standards Source License Version 1.2
*
* Sun Microsystems Inc., March, 2001
*
*
* Sun Industry Standards Source License Version 1.2
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.2 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2001 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
************************************************************************/
/*___INFO__MARK_END__*/
#include <stdio.h>
#include "drmaa.h"
int main (int argc, char **argv) {
char error[DRMAA_ERROR_STRING_BUFFER];
int errnum = 0;
drmaa_job_template_t *jt = NULL;
errnum = drmaa_init (NULL, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not initialize the DRMAA library: %s\n", error);
return 1;
}
errnum = drmaa_allocate_job_template (&jt, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not create job template: %s\n", error);
}
else {
errnum = drmaa_set_attribute (jt, DRMAA_REMOTE_COMMAND, "sleeper.sh",
error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not set attribute \"%s\": %s\n",
DRMAA_REMOTE_COMMAND, error);
}
else {
const char *args[2] = {"5", NULL};
errnum = drmaa_set_vector_attribute (jt, DRMAA_V_ARGV, args, error,
DRMAA_ERROR_STRING_BUFFER);
}
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not set attribute \"%s\": %s\n",
DRMAA_REMOTE_COMMAND, error);
}
else {
drmaa_job_ids_t *ids = NULL;
errnum = drmaa_run_bulk_jobs (&ids, jt, 1, 30, 2, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not submit job: %s\n", error);
}
else {
char jobid[DRMAA_JOBNAME_BUFFER];
while (drmaa_get_next_job_id (ids, jobid, DRMAA_JOBNAME_BUFFER) == DRMAA_ERRNO_SUCCESS) {
printf ("A job task has been submitted with id %s\n", jobid);
}
}
drmaa_release_job_ids (ids);
}
errnum = drmaa_delete_job_template (jt, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not delete job template: %s\n", error);
}
} /* else */
errnum = drmaa_exit (error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not shut down the DRMAA library: %s\n", error);
return 1;
}
return 0;
}

156
examples/drmaa/howto3.c Executable file
View File

@ -0,0 +1,156 @@
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* the Sun Industry Standards Source License Version 1.2
*
* Sun Microsystems Inc., March, 2001
*
*
* Sun Industry Standards Source License Version 1.2
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.2 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2001 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
************************************************************************/
/*___INFO__MARK_END__*/
#include <stdio.h>
#include "drmaa.h"
int main (int argc, char **argv) {
char error[DRMAA_ERROR_STRING_BUFFER];
int errnum = 0;
drmaa_job_template_t *jt = NULL;
errnum = drmaa_init (NULL, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not initialize the DRMAA library: %s\n", error);
return 1;
}
errnum = drmaa_allocate_job_template (&jt, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not create job template: %s\n", error);
}
else {
errnum = drmaa_set_attribute (jt, DRMAA_REMOTE_COMMAND, "sleeper.sh",
error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not set attribute \"%s\": %s\n",
DRMAA_REMOTE_COMMAND, error);
}
else {
const char *args[2] = {"5", NULL};
errnum = drmaa_set_vector_attribute (jt, DRMAA_V_ARGV, args, error,
DRMAA_ERROR_STRING_BUFFER);
}
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not set attribute \"%s\": %s\n",
DRMAA_REMOTE_COMMAND, error);
}
else {
char jobid[DRMAA_JOBNAME_BUFFER];
char jobid_out[DRMAA_JOBNAME_BUFFER];
int status = 0;
drmaa_attr_values_t *rusage = NULL;
errnum = drmaa_run_job (jobid, DRMAA_JOBNAME_BUFFER, jt, error,
DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not submit job: %s\n", error);
}
else {
printf ("Your job has been submitted with id %s\n", jobid);
errnum = drmaa_wait (jobid, jobid_out, DRMAA_JOBNAME_BUFFER, &status,
DRMAA_TIMEOUT_WAIT_FOREVER, &rusage, error,
DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not wait for job: %s\n", error);
}
else {
char usage[DRMAA_ERROR_STRING_BUFFER];
int aborted = 0;
drmaa_wifaborted(&aborted, status, NULL, 0);
if (aborted == 1) {
printf("Job %s never ran\n", jobid);
}
else {
int exited = 0;
drmaa_wifexited(&exited, status, NULL, 0);
if (exited == 1) {
int exit_status = 0;
drmaa_wexitstatus(&exit_status, status, NULL, 0);
printf("Job %s finished regularly with exit status %d\n", jobid, exit_status);
}
else {
int signaled = 0;
drmaa_wifsignaled(&signaled, status, NULL, 0);
if (signaled == 1) {
char termsig[DRMAA_SIGNAL_BUFFER+1];
drmaa_wtermsig(termsig, DRMAA_SIGNAL_BUFFER, status, NULL, 0);
printf("Job %s finished due to signal %s\n", jobid, termsig);
}
else {
printf("Job %s finished with unclear conditions\n", jobid);
}
} /* else */
} /* else */
printf ("Job Usage:\n");
while (drmaa_get_next_attr_value (rusage, usage, DRMAA_ERROR_STRING_BUFFER) == DRMAA_ERRNO_SUCCESS) {
printf (" %s\n", usage);
}
drmaa_release_attr_values (rusage);
} /* else */
} /* else */
} /* else */
errnum = drmaa_delete_job_template (jt, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not delete job template: %s\n", error);
}
} /* else */
errnum = drmaa_exit (error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not shut down the DRMAA library: %s\n", error);
return 1;
}
return 0;
}

116
examples/drmaa/howto3_1.c Executable file
View File

@ -0,0 +1,116 @@
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* the Sun Industry Standards Source License Version 1.2
*
* Sun Microsystems Inc., March, 2001
*
*
* Sun Industry Standards Source License Version 1.2
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.2 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2001 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
************************************************************************/
/*___INFO__MARK_END__*/
#include <stdio.h>
#include "drmaa.h"
int main (int argc, char **argv) {
char error[DRMAA_ERROR_STRING_BUFFER];
int errnum = 0;
drmaa_job_template_t *jt = NULL;
errnum = drmaa_init (NULL, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not initialize the DRMAA library: %s\n", error);
return 1;
}
errnum = drmaa_allocate_job_template (&jt, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not create job template: %s\n", error);
}
else {
errnum = drmaa_set_attribute (jt, DRMAA_REMOTE_COMMAND, "sleeper.sh",
error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not set attribute \"%s\": %s\n",
DRMAA_REMOTE_COMMAND, error);
}
else {
const char *args[2] = {"5", NULL};
errnum = drmaa_set_vector_attribute (jt, DRMAA_V_ARGV, args, error,
DRMAA_ERROR_STRING_BUFFER);
}
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not set attribute \"%s\": %s\n",
DRMAA_REMOTE_COMMAND, error);
}
else {
drmaa_job_ids_t *ids = NULL;
errnum = drmaa_run_bulk_jobs (&ids, jt, 1, 30, 2, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not submit job: %s\n", error);
}
else {
char jobid[DRMAA_JOBNAME_BUFFER];
const char *jobids[2] = {DRMAA_JOB_IDS_SESSION_ALL, NULL};
while (drmaa_get_next_job_id (ids, jobid, DRMAA_JOBNAME_BUFFER) == DRMAA_ERRNO_SUCCESS) {
printf ("A job task has been submitted with id %s\n", jobid);
}
errnum = drmaa_synchronize (jobids, DRMAA_TIMEOUT_WAIT_FOREVER,
1, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not wait for jobs: %s\n", error);
}
else {
printf ("All job tasks have finished.\n");
}
} /* else */
drmaa_release_job_ids (ids);
} /* else */
errnum = drmaa_delete_job_template (jt, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not delete job template: %s\n", error);
}
} /* else */
errnum = drmaa_exit (error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not shut down the DRMAA library: %s\n", error);
return 1;
}
return 0;
}

182
examples/drmaa/howto3_2.c Executable file
View File

@ -0,0 +1,182 @@
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* the Sun Industry Standards Source License Version 1.2
*
* Sun Microsystems Inc., March, 2001
*
*
* Sun Industry Standards Source License Version 1.2
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.2 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2001 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
************************************************************************/
/*___INFO__MARK_END__*/
#include <stdio.h>
#include "drmaa.h"
int main (int argc, char **argv) {
char error[DRMAA_ERROR_STRING_BUFFER];
int errnum = 0;
drmaa_job_template_t *jt = NULL;
errnum = drmaa_init (NULL, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not initialize the DRMAA library: %s\n", error);
return 1;
}
errnum = drmaa_allocate_job_template (&jt, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not create job template: %s\n", error);
}
else {
errnum = drmaa_set_attribute (jt, DRMAA_REMOTE_COMMAND, "sleeper.sh",
error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not set attribute \"%s\": %s\n",
DRMAA_REMOTE_COMMAND, error);
}
else {
const char *args[2] = {"5", NULL};
errnum = drmaa_set_vector_attribute (jt, DRMAA_V_ARGV, args, error,
DRMAA_ERROR_STRING_BUFFER);
}
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not set attribute \"%s\": %s\n",
DRMAA_REMOTE_COMMAND, error);
}
else {
drmaa_job_ids_t *ids = NULL;
int start = 1;
int end = 30;
int step = 2;
errnum = drmaa_run_bulk_jobs (&ids, jt, start, end, step, error,
DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not submit job: %s\n", error);
}
else {
char jobid[DRMAA_JOBNAME_BUFFER];
const char *jobids[2] = {DRMAA_JOB_IDS_SESSION_ALL, NULL};
while (drmaa_get_next_job_id (ids, jobid, DRMAA_JOBNAME_BUFFER)
== DRMAA_ERRNO_SUCCESS) {
printf ("A job task has been submitted with id %s\n", jobid);
}
errnum = drmaa_synchronize (jobids, DRMAA_TIMEOUT_WAIT_FOREVER,
0, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not wait for jobs: %s\n", error);
}
else {
char jobid[DRMAA_JOBNAME_BUFFER];
int status = 0;
drmaa_attr_values_t *rusage = NULL;
int count = 0;
for (count = start; count < end; count += step) {
errnum = drmaa_wait (DRMAA_JOB_IDS_SESSION_ANY, jobid,
DRMAA_JOBNAME_BUFFER, &status,
DRMAA_TIMEOUT_WAIT_FOREVER, &rusage,
error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not wait for job: %s\n", error);
}
else {
char usage[DRMAA_ERROR_STRING_BUFFER];
int aborted = 0;
drmaa_wifaborted(&aborted, status, NULL, 0);
if (aborted == 1) {
printf("Job %s never ran\n", jobid);
}
else {
int exited = 0;
drmaa_wifexited(&exited, status, NULL, 0);
if (exited == 1) {
int exit_status = 0;
drmaa_wexitstatus(&exit_status, status, NULL, 0);
printf("Job %s finished regularly with exit status %d\n",
jobid, exit_status);
}
else {
int signaled = 0;
drmaa_wifsignaled(&signaled, status, NULL, 0);
if (signaled == 1) {
char termsig[DRMAA_SIGNAL_BUFFER+1];
drmaa_wtermsig(termsig, DRMAA_SIGNAL_BUFFER, status, NULL, 0);
printf("Job %s finished due to signal %s\n", jobid, termsig);
}
else {
printf("Job %s finished with unclear conditions\n", jobid);
}
} /* else */
} /* else */
printf ("Job Usage:\n");
while (drmaa_get_next_attr_value (rusage, usage, DRMAA_ERROR_STRING_BUFFER)
== DRMAA_ERRNO_SUCCESS) {
printf (" %s\n", usage);
}
drmaa_release_attr_values (rusage);
} /* else */
} /* for */
} /* else */
} /* else */
drmaa_release_job_ids (ids);
} /* else */
errnum = drmaa_delete_job_template (jt, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not delete job template: %s\n", error);
}
} /* else */
errnum = drmaa_exit (error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not shut down the DRMAA library: %s\n", error);
return 1;
}
return 0;
}

110
examples/drmaa/howto4.c Executable file
View File

@ -0,0 +1,110 @@
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* the Sun Industry Standards Source License Version 1.2
*
* Sun Microsystems Inc., March, 2001
*
*
* Sun Industry Standards Source License Version 1.2
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.2 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2001 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
************************************************************************/
/*___INFO__MARK_END__*/
#include <stdio.h>
#include "drmaa.h"
int main (int argc, char **argv) {
char error[DRMAA_ERROR_STRING_BUFFER];
int errnum = 0;
drmaa_job_template_t *jt = NULL;
errnum = drmaa_init (NULL, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not initialize the DRMAA library: %s\n", error);
return 1;
}
errnum = drmaa_allocate_job_template (&jt, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not create job template: %s\n", error);
}
else {
errnum = drmaa_set_attribute (jt, DRMAA_REMOTE_COMMAND, "sleeper.sh",
error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not set attribute \"%s\": %s\n",
DRMAA_REMOTE_COMMAND, error);
}
else {
const char *args[2] = {"60", NULL};
errnum = drmaa_set_vector_attribute (jt, DRMAA_V_ARGV, args, error,
DRMAA_ERROR_STRING_BUFFER);
}
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not set attribute \"%s\": %s\n",
DRMAA_REMOTE_COMMAND, error);
}
else {
char jobid[DRMAA_JOBNAME_BUFFER];
errnum = drmaa_run_job (jobid, DRMAA_JOBNAME_BUFFER, jt, error,
DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not submit job: %s\n", error);
}
else {
printf ("Your job has been submitted with id %s\n", jobid);
errnum = drmaa_control (jobid, DRMAA_CONTROL_TERMINATE, error,
DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not delete job: %s\n", error);
}
else {
printf ("Your job has been deleted\n");
}
}
} /* else */
errnum = drmaa_delete_job_template (jt, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not delete job template: %s\n", error);
}
} /* else */
errnum = drmaa_exit (error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not shut down the DRMAA library: %s\n", error);
return 1;
}
return 0;
}

149
examples/drmaa/howto5.c Executable file
View File

@ -0,0 +1,149 @@
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* the Sun Industry Standards Source License Version 1.2
*
* Sun Microsystems Inc., March, 2001
*
*
* Sun Industry Standards Source License Version 1.2
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.2 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2001 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
************************************************************************/
/*___INFO__MARK_END__*/
#include <stdio.h>
#include <unistd.h>
#include "drmaa.h"
int main (int argc, char **argv) {
char error[DRMAA_ERROR_STRING_BUFFER];
int errnum = 0;
drmaa_job_template_t *jt = NULL;
errnum = drmaa_init (NULL, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not initialize the DRMAA library: %s\n", error);
return 1;
}
errnum = drmaa_allocate_job_template (&jt, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not create job template: %s\n", error);
}
else {
errnum = drmaa_set_attribute (jt, DRMAA_REMOTE_COMMAND, "sleeper.sh",
error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not set attribute \"%s\": %s\n",
DRMAA_REMOTE_COMMAND, error);
}
else {
const char *args[2] = {"60", NULL};
errnum = drmaa_set_vector_attribute (jt, DRMAA_V_ARGV, args, error,
DRMAA_ERROR_STRING_BUFFER);
}
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not set attribute \"%s\": %s\n",
DRMAA_REMOTE_COMMAND, error);
}
else {
char jobid[DRMAA_JOBNAME_BUFFER];
errnum = drmaa_run_job (jobid, DRMAA_JOBNAME_BUFFER, jt, error,
DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not submit job: %s\n", error);
}
else {
int status = 0;
printf ("Your job has been submitted with id %s\n", jobid);
sleep (20);
errnum = drmaa_job_ps (jobid, &status, error,
DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not get job' status: %s\n", error);
}
else {
switch (status) {
case DRMAA_PS_UNDETERMINED:
printf ("Job status cannot be determined\n");
break;
case DRMAA_PS_QUEUED_ACTIVE:
printf ("Job is queued and active\n");
break;
case DRMAA_PS_SYSTEM_ON_HOLD:
printf ("Job is queued and in system hold\n");
break;
case DRMAA_PS_USER_ON_HOLD:
printf ("Job is queued and in user hold\n");
break;
case DRMAA_PS_USER_SYSTEM_ON_HOLD:
printf ("Job is queued and in user and system hold\n");
break;
case DRMAA_PS_RUNNING:
printf ("Job is running\n");
break;
case DRMAA_PS_SYSTEM_SUSPENDED:
printf ("Job is system suspended\n");
break;
case DRMAA_PS_USER_SUSPENDED:
printf ("Job is user suspended\n");
break;
case DRMAA_PS_USER_SYSTEM_SUSPENDED:
printf ("Job is user and system suspended\n");
break;
case DRMAA_PS_DONE:
printf ("Job finished normally\n");
break;
case DRMAA_PS_FAILED:
printf ("Job finished, but failed\n");
break;
} /* switch */
} /* else */
} /* else */
} /* else */
errnum = drmaa_delete_job_template (jt, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not delete job template: %s\n", error);
}
} /* else */
errnum = drmaa_exit (error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not shut down the DRMAA library: %s\n", error);
return 1;
}
return 0;
}

128
examples/drmaa/howto6.c Executable file
View File

@ -0,0 +1,128 @@
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* the Sun Industry Standards Source License Version 1.2
*
* Sun Microsystems Inc., March, 2001
*
*
* Sun Industry Standards Source License Version 1.2
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.2 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2001 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
************************************************************************/
/*___INFO__MARK_END__*/
#include <stdio.h>
#include "drmaa.h"
int main (int argc, char **argv) {
char error[DRMAA_ERROR_STRING_BUFFER];
int errnum = 0;
char contact[DRMAA_CONTACT_BUFFER];
char drm_system[DRMAA_DRM_SYSTEM_BUFFER];
char drmaa_impl[DRMAA_DRM_SYSTEM_BUFFER];
unsigned int major = 0;
unsigned int minor = 0;
errnum = drmaa_get_contact (contact, DRMAA_CONTACT_BUFFER, error,
DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not get the contact string list: %s\n", error);
}
else {
printf ("Supported contact strings: \"%s\"\n", contact);
}
errnum = drmaa_get_DRM_system (drm_system, DRMAA_DRM_SYSTEM_BUFFER, error,
DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not get the DRM system list: %s\n", error);
}
else {
printf ("Supported DRM systems: \"%s\"\n", drm_system);
}
errnum = drmaa_get_DRMAA_implementation (drmaa_impl, DRMAA_DRM_SYSTEM_BUFFER,
error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not get the DRMAA implementation list: %s\n", error);
}
else {
printf ("Supported DRMAA implementations: \"%s\"\n", drmaa_impl);
}
errnum = drmaa_init (NULL, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not initialize the DRMAA library: %s\n", error);
return 1;
}
errnum = drmaa_get_contact (contact, DRMAA_CONTACT_BUFFER, error,
DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not get the contact string: %s\n", error);
}
else {
printf ("Connected contact string: \"%s\"\n", contact);
}
errnum = drmaa_get_DRM_system (drm_system, DRMAA_CONTACT_BUFFER, error,
DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not get the DRM system: %s\n", error);
}
else {
printf ("Connected DRM system: \"%s\"\n", drm_system);
}
errnum = drmaa_get_DRMAA_implementation (drmaa_impl, DRMAA_DRM_SYSTEM_BUFFER,
error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not get the DRMAA implementation list: %s\n", error);
}
else {
printf ("Supported DRMAA implementations: \"%s\"\n", drmaa_impl);
}
errnum = drmaa_version (&major, &minor, error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not get the DRMAA version: %s\n", error);
}
else {
printf ("Using DRMAA version %d.%d\n", major, minor);
}
errnum = drmaa_exit (error, DRMAA_ERROR_STRING_BUFFER);
if (errnum != DRMAA_ERRNO_SUCCESS) {
fprintf (stderr, "Could not shut down the DRMAA library: %s\n", error);
return 1;
}
return 0;
}

77
examples/drmaa/ruby/array.rb Executable file
View File

@ -0,0 +1,77 @@
#!/usr/bin/ruby
#########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2006
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2006 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
#########################################################################
require 'drmaa'
class Sleeper < DRMAA::JobTemplate
def initialize
super
self.command = "/bin/sleep"
self.arg = ["1"]
self.stdout = ":/dev/null"
self.join = true
end
end
# Two array jobs are submitted. The second array task remains in
# hold until the predecessor task was run. Demonstrate possible
# use of hold/release.
NTASKS = 30
session = DRMAA::Session.new
jt = Sleeper.new
pre = session.run_bulk(jt, 1, NTASKS, 1)
suc = session.run_bulk(jt, 1, NTASKS, 1)
h = Hash.new
for i in 0 .. NTASKS-1 do
h[pre[i]] = suc[i]
end
session.wait_each{ |info|
job = info.job
if h.has_key?(job)
session.release(h[job])
end
if info.wifexited?
puts job + " returned with " + info.wexitstatus.to_s
# info.rusage.each { |u| puts "usage " + u }
elsif info.wifaborted?
puts job + " aborted"
elsif info.wifsignaled?
puts job + " died from " + info.wtermsig
end
}
exit 0

View File

@ -0,0 +1,49 @@
#!/usr/bin/ruby
#########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2006
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2006 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
#########################################################################
require 'drmaa'
version = DRMAA.version
drm = DRMAA.drm_system
impl = DRMAA.drmaa_implementation
contact = DRMAA.contact
puts "DRMAA: #{drm} version #{version} impl #{impl} contact #{contact}"
session = DRMAA::Session.new
puts "supported DRMAA job template attributes:"
attrs = DRMAA.attributes.each { |n| puts " #{n}" }
puts "supported DRMAA job template vector attributes:"
attrs = DRMAA.vector_attributes.each { |n| puts " #{n}" }
exit 0

70
examples/drmaa/ruby/example.rb Executable file
View File

@ -0,0 +1,70 @@
#!/usr/bin/ruby
#########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2006
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2006 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
#########################################################################
require 'drmaa'
class Sleeper < DRMAA::JobTemplate
def initialize
super
self.command = "/bin/sleep"
self.arg = ["1"]
self.stdout = ":/dev/null"
self.join = true
end
end
version = DRMAA.version
drm = DRMAA.drm_system
impl = DRMAA.drmaa_implementation
contact = DRMAA.contact
puts "DRMAA #{drm} v #{version} impl #{impl} contact #{contact}"
session = DRMAA::Session.new
t = Sleeper.new
jobid = session.run(t)
puts "job: " + jobid
session.run_bulk(t, 1, 20).each { |job|
puts "job: " + job
}
session.wait_each{ |info|
if ! info.wifexited?
puts "failed: " + info.job
else
puts info.job + " returned with " + info.wexitstatus.to_s
end
}
exit 0

39
examples/drmaa/ruby/flow/README Executable file
View File

@ -0,0 +1,39 @@
== Workflow interpreter and processor
flow.rb is a utility for running job workflows in
DRMAA-compliant DRM systems. Workflows are specified in
flowfiles that allow expression of
* concurrent and sequential execution of sub-flows
* multiple runs of sub-flows with varying parameter sets
* actual jobs are defined in terms of DRMAA attributes
in addition any subflow or sets of subflows can be run
as used with make(1) by specifying it as target.
=== Job defaults
To minimize the extent of attributes necessarily
specified in flowfiles, flow.rb provides defaults for
jobs' command path, stdout/stdin path, current working
directory and job name.
=== Workflow verification
The -verify option can be used to print dependencies and
job attributes for diagnosis purposes. To ensure each
workflow job can be run, a number of verifications is
performed before the first job gets submitted.
=== Job streaming
Large workflows are automatically run in job streaming mode
upon DRM saturation and a job maximum can be set in .flowrc.rb
to place an upper limit of jobs be kept concurrently in the
DRM for each workflow.
=== Pre-submission plug-in
Enforcement of site-specific policies can easily be
achieved through pre-submission procedures that allow
any job attribute to be modified freely.

911
examples/drmaa/ruby/flow/flow.rb Executable file
View File

@ -0,0 +1,911 @@
#!/usr/bin/ruby
#########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2006
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2006 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
#########################################################################
# TODO:
# - provide means to restart entire flows with failed flowjobs be rerun only
# - support bulk jobs
# - allow DRMAA user hold be used despite user hold be used by flow itself
#########################################################################
require 'drmaa'
# ------------------------------------------------------------------------------------------
# Exceptions thrown during parsing stage
class ParsingFunction < ArgumentError ; end
class ParsingFormat < ArgumentError ; end
# ------------------------------------------------------------------------------------------
# The FlowFunction classes represent the entities found in the flowfile.
class FlowFunction
end
class JobsInParallel < FlowFunction
attr_accessor :par
def make(key, vars, depend, depth, select)
do_it = select_func?(key, vars, select)
all_jobs = Array.new
@par.each { |sub|
name = sub[0]
if do_it
flowprint(depth, "PARALLEL: " + name)
end
new_vars = sub[1]
sub_vars = vars.dup
if ! new_vars.nil?
new_vars.each_pair { |var,val| sub_vars[var] = val }
end
j = $flowfunction[name]
if j.nil?
raise ParsingFunction.new("#{key}(): flow function \"#{name}\" does not exit")
end
if do_it
jobs = j.make(name, sub_vars, depend, depth+1, nil)
else
jobs = j.make(name, sub_vars, depend, depth+1, select)
end
if ! jobs.nil?
all_jobs += jobs
end
}
if all_jobs.size != 0
return all_jobs
else
return nil
end
end
end
class JobsInSequence < FlowFunction
attr_accessor :seq
def make(key, vars, depend, depth, select)
do_it = select_func?(key, vars, select)
first = true
@seq.each { |sub|
name = sub[0]
flowprint(depth, "SEQUENTIAL: " + name) if do_it
new_vars = sub[1]
sub_vars = vars.dup
if ! new_vars.nil?
new_vars.each_pair { |var,val| sub_vars[var] = val }
end
j = $flowfunction[name]
if j.nil?
raise ParsingFunction.new("#{key}: flow function \"#{name}\" does not exit")
end
if do_it
depend = j.make(name, sub_vars, depend, depth+1, nil)
else
depend = j.make(name, sub_vars, depend, depth+1, select)
end
}
return depend
end
end
class RunnableJob < FlowFunction
attr_accessor :attrs, :njobs
def initialize
@njobs = 0
end
def make(key, vars, depend, depth, select)
@njobs += 1
job_key = key + "#" + @njobs.to_s
do_it = select_func?(key, vars, select)
fj_attrs = Array.new
@attrs.each_pair { |name,t|
value = substitute(t, vars)
fj_attrs.push([ name, value ])
}
if depend.nil?
f = FlowJob.new(nil, fj_attrs)
flowprint(depth, job_key + "(" + comma_vars(vars) + ")") if do_it
else
f = FlowJob.new(depend.dup, fj_attrs)
flowprint(depth, job_key + "(" + comma_vars(vars) + ") waiting for " + comma_jobs(f.depend, ", ")) if do_it
end
fj_attrs.each { |a| flowprint(depth+1, a[0] + "=\"" + a[1] + "\"") } if do_it
f.presubproc(job_key)
f.verify(job_key)
if ! do_it
$not_selected += 1
return [ ]
end
$flowjob[job_key] = f
return [ job_key ]
end
end
def flowprint(depth, s)
return if ! $parse_only
(depth*3).times { putc " " } ; puts s
end
def comma_vars(vars)
s = ""
first = true
vars.each_pair { |var,val|
if first == false
s += ", "
else
first = false
end
s += var + "=" + val
}
return s
end
def comma_jobs(jobs, sep = ",")
s = ""
first = true
jobs.each { |job|
if first == false
s += sep
else
first = false
end
s += job
}
return s
end
def substitute(s, vars)
vars.each_pair { |var,val|
s = s.sub(var, val)
}
return s
end
# parses name1=value1,... into a Hash
# used both for params and attrs
def var_list(str)
vars = Hash.new
if ! str.nil?
str.strip.scan(/[^,][^,]*/) { |vardef|
n = vardef.strip.scan(/[^=][^=]*/)
vars[n[0].strip] = n[1].strip
}
end
return vars
end
# decide if a paricular flow call was selected as target
def select_func?(k1, vrs1, select)
return true if select.nil?
k2 = select[0]
vrs2 = select[1]
if k1 != k2 or vrs1.size < vrs2.size
return false
end
vrs2.each_pair { |k,v|
if ! vrs1.has_key?(k) or vrs1[k] != v
return false
end
}
return true
end
# return name of first function
def parse_flow(file)
all = nil
begin
IO::foreach(file) { |line|
case line
when /^#/
next
else
# crack line
function = line.sub(/[ ]*=.*$/, "").strip
val = line.sub(/^[^=]*=/, "").strip
if all.nil?
all = function
end
# runnable job
if ! val.index("{").nil?
r = RunnableJob.new
jobdef = val.scan(/[^{}][^{}]*/)[0].strip
r.attrs = var_list(jobdef)
$flowfunction[function] = r
# jobs in parallel
elsif ! val.index("&").nil?
p = JobsInParallel.new
p.par = Array.new
val.scan(/[^&][^&]*/) { |sub| p.par << parse_flowcall(sub) }
$flowfunction[function] = p
# jobs in sequence
elsif ! val.index("|").nil?
s = JobsInSequence.new
s.seq = Array.new
val.scan(/[^|][^|]*/) { |sub| s.seq << parse_flowcall(sub) }
$flowfunction[function] = s
else
# parsing code possibly is not yet good enoug -- sorryh
raise ParsingFormat.new("flow file may not have empty lines")
end
end
}
end
return all
end
def parse_flowcall(s)
jobdef = s.strip.scan(/[^()][^()]*/)
key = jobdef[0].strip
vars = var_list(jobdef[1])
return [ key, vars ]
end
# ------------------------------------------------------------------------------------------
# At end of parsing stage there is one FlowJob for each job to be run.
# The FlowJob also keeps state information, dependency information and
# job finish information.
class FlowJob
# configuration
attr_accessor :attrs, :depend
# state information
attr_accessor :jobid, :info
def initialize(depend, attrs)
@depend = depend
@attrs = attrs
end
# -- verification
def verify(key)
cmd = false
@attrs.each { |a|
name = a[0]
value = a[1]
if value.index('$')
raise ParsingFunction.new("#{key}: #{name}=#{value} contains \"$\"")
end
case name
when "cmd"
if value.index('/') == 0
if ! File.executable?(value)
raise ParsingFunction.new("#{key}: cmd=#{value} must be executable")
end
else
if executable_cmd(value).nil?
raise ParsingFunction.new("#{key}: could't find cmd=#{value} in CMDPATH")
end
end
cmd = true
when "join", "nomail"
true_or_false?(key, name, value)
when "args", "name", "nat", "cat", "wd", "in", "out", "err", "join", "trans", "mail"
else
# bug: must use DRMAA.get_attribute_names() to detect use of invalid attributes
raise ParsingFunction.new("#{key}: unknown attribute \"#{name}\"")
end
}
if !cmd
raise ParsingFunction.new("#{key}: missing mandatory attribute \"cmd\"")
end
end
def presubproc(job_key)
if defined? FlowRC.presubmit_proc
FlowRC.presubmit_proc(job_key, @attrs)
end
end
def executable_cmd(cmd)
path = nil
$CMDPATH.each { |p|
if File.executable?(p + "/" + cmd)
path = p + "/" + cmd
break
end
}
return path
end
def true_or_false?(key, name, value)
case value
when "0", "false", "no", "n"
return false
when "1", "true", "yes", "y"
return true
else
raise ParsingFunction.new("#{key}: \"#{name}=#{value}\" is neither \"true\" nor \"false\"")
end
end
def submit(key, predecessors)
if $MAX_JOBS != 0 and $jobs_in_drm == $MAX_JOBS
return false
end
jt = DRMAA::JobTemplate.new
# job defaults
jt.name = key # flow job name
if $flowdir.nil?
jt.wd = $wd
jt.stdout = ":/dev/null"
jt.join = true
else
jt.wd = $flowdir
jt.stdout = ":#{$flowdir}/#{key}.o"
jt.stderr = ":#{$flowdir}/#{key}.e"
jt.join = false
end
native = nil
attrs.each { |a|
name = a[0]
value = a[1]
case name
when "cmd"
if value.index("/") == 0
jt.command = value
else
jt.command = executable_cmd(value)
end
when "args"
jt.arg = value.split(" ")
when "env"
jt.env = value.split(",")
when "name"
jt.name = value
when "nat"
native = value
when "cat"
jt.category = value
when "hold"
# careful! hold is used by flow itself
# jt.hold = true_or_false?(key, name, value)
when "wd"
jt.wd = value
when "in"
jt.stdin = value
when "out"
jt.stdout = value
when "err"
jt.stderr = value
when "join"
jt.join = true_or_false?(key, name, value)
when "trans"
jt.transfer = value
when "mail"
jt.mail = value.split(",")
when "nomail"
jt.block_mail = true_or_false?(key, name, value)
end
}
if ! predecessors.nil?
if $drm_depend
if native.nil?
jt.native = "-hold_jid " + predecessors
else
jt.native = native + " -hold_jid " + predecessors
end
else
jt.hold = true
jt.native = native unless native.nil?
end
else
jt.native = native unless native.nil?
end
begin
jobid = $session.run(jt)
$already_submitted += 1
$last_submission = Time.now
@jobid = jobid
if ! predecessors.nil?
puts "#{key} " + jobid + " submitted depending on " + predecessors
else
puts "#{key} " + jobid + " submitted"
end
rescue DRMAA::DRMAATryLater
STDERR.puts "... try later (#{key})"
return false
end
$jobs_in_drm += 1
return true
end
# true, if all predecessors done
def is_due?
return true if @depend.nil?
self.depend.each { |key|
info = $flowjob[key].info
if info.nil?
return false # not yet finished
end
if ! info.wifexited? or info.wexitstatus != 0
return false # failed
end
}
return true
end
def can_submit
# now --> [0, jobids]
# later --> [1, nil]
# never --> [2, nil]
r = 0
jobids = nil
self.depend.each { |key|
node = $flowjob[key]
info = node.info
if ! info.nil?
if !info.wifexited? or info.wexitstatus != 0
return [ 2, nil] # failed
else
next # done
end
end
jobid = node.jobid
if jobid.nil?
r = 1 # predecessor not yet submitted
else
# collect jobids
if jobids.nil?
jobids = jobid
else
jobids += "," + jobid
end
end
}
if r == 1
return [1,nil]
else
return [0,jobids]
end
end
end
# ------------------------------------------------------------------------------------------
# The functions below are used by main to run the workflow and cause
# successor jobs be submitted/released once they are due.
# Workflow optimization requires job be submitted in order
# pass (1): jobs without predecessors or with all predecessors run
# pass (2): jobs whose predecessors are submitted
# aims is as broad as possible flow submission.
def submit_jobs(flush)
if $flowjob.size == $already_submitted or $terminate_session
# STDERR.puts "all jobs submitted"
return true # all submitted
end
if ! flush
if $last_submission != 0 and (Time.now - $last_submission) < $STREAMING_RETRY
# puts "... retry not yet reached"
return false # retry not yet reached
end
end
# STDERR.puts "1st pass"
$flowjob.each_pair { |key,fj|
next if ! fj.jobid.nil? # already submitted
next if ! fj.info.nil? # already finished
# all predecessors done
next if ! fj.is_due?
if ! fj.submit(key, nil)
return false # try again
end
if $terminate_program
exit 1
elsif $terminate_session
terminate()
return true
end
}
begin
# STDERR.puts "2nd pass"
all_submitted = true
$flowjob.each_pair { |key,fj|
next if ! fj.jobid.nil? # already submitted
next if ! fj.info.nil? # already finished
# analyze predecessors
status = fj.can_submit()
if status[0] != 0
all_submitted = false if status[0] == 1
next
end
predecessors = status[1]
if ! fj.submit(key, predecessors)
return false # try again
end
if $terminate_program
exit 1
elsif $terminate_session
terminate()
return true
end
}
end until all_submitted
return true # all submitted
end
def reap_jobs
$session.wait_each(1) { |info|
# delete workflow upon user interrupt
if $terminate_program
exit 1
elsif $terminate_session
terminate()
end
# nothing happend
if info.nil?
submit_jobs(false)
next
end
$jobs_in_drm -= 1
# interpret job finish information
if info.wifaborted?
failed = true
happend = "aborted"
caused = "terminated"
elsif info.wifsignaled?
failed = true
happend = "died from " + info.wtermsig
happend += " (core dump)" if info.wcoredump?
caused = "terminated"
elsif info.wifexited?
exit_status = info.wexitstatus
if exit_status != 0
failed = true
happend = "exited with " + exit_status.to_s
caused = "terminated"
else
failed = false
happend = "done"
caused = "released"
end
end
# search flow job
job_key = nil
fjob = nil
$flowjob.each_pair { |k,v|
if v.jobid.nil?
next
end
if v.jobid == info.job
job_key = k
fjob = v
break
end
}
if fjob.nil?
puts "missing flow job for finished job " + info.job
exit 1
end
# mark flow job as done
fjob.info = info
fjob.jobid = nil
trigger = Array.new
if ! $terminate_session
# drive conclusions
$flowjob.each_pair { |k,v|
# finished and non-blocked ones: skip
next if ! v.info.nil? or v.depend.nil? or v.jobid.nil?
# dependend to others: skip
next if ! v.depend.include?(job_key)
if failed
begin
$session.terminate(v.jobid)
rescue DRMAA::DRMAAInvalidJobError
end
trigger << v.jobid
else
do_rls = true
v.depend.each { |k|
do_rls = false if $flowjob[k].info.nil?
}
if do_rls and ! $drm_depend
$session.release(v.jobid)
trigger << v.jobid
end
end
}
end
# report what happend
if trigger.size == 0
puts "#{job_key} #{info.job} " + happend
else
puts "#{job_key} #{info.job} " + happend + " " + caused + " " + comma_jobs(trigger, ", ")
end
submit_jobs(false)
}
end
# show final statistics
def final_report
nfailed = 0
nrun = 0
nnotrun = 0
rusage = Hash.new
$flowjob.each_pair { |k,v|
if v.info.nil?
nnotrun += 1
next
end
if ! v.info.wifexited? or v.info.wexitstatus != 0
nfailed += 1
else
nrun += 1
end
usage = v.info.rusage
next if usage.nil?
usage.each_pair { |name,value|
if $USAGE_REPORT.include?(name)
if ! rusage.has_key?(name)
rusage[name] = value.to_f
else
rusage[name] += value.to_f
end
end
}
}
puts "# ---- final report"
rusage.each_pair { |name,value|
printf("usage: #{name} = %-7.2f\n", value)
}
puts "run: #{nrun} failed: #{nfailed} notrun: #{nnotrun}"
end
def terminate
if ! $did_terminate
STDERR.puts "Terminate!"
$session.terminate
$did_terminate = true
end
end
def handle_signal
if ! $terminate_session
$terminate_session = true
elsif ! $terminate_program
$terminate_program = true
end
end
def usage(ret)
if ret == 0
out = STDOUT
else
out = STDERR
end
out.puts "usage: flow.rb [options] workflow.ff [start]"
out.puts " options: -verify only parse and verify the flow"
out.puts " -dd use DRM dependencies"
out.puts " -flowdir <path> flowdir is used as defaults"
out.puts " start: <flowcall> --> TEST or TEST($arch=solaris)"
exit ret
end
# ------------------------------------------------------------------------------------------
# main
# use defaults
# (1) from ./.flowrc.rb
# (2) from $HOME/.flowrc.rb
# (3) or built-in ones
read_rc_file = false
if FileTest.exist?('.flowrc.rb')
require '.flowrc'
read_rc_file = true
elsif FileTest.exist?(ENV["HOME"] + "/.flowrc.rb")
require ENV["HOME"] + "/.flowrc.rb"
read_rc_file = true
end
if ! read_rc_file
$CMDPATH = Dir::getwd()
$STREAMING_RETRY = 5
$USAGE_REPORT = [ ]
$MAX_JOBS = 0
else
$CMDPATH = FlowRC::CMDPATH
$STREAMING_RETRY = FlowRC::STREAMING_RETRY
$USAGE_REPORT = FlowRC::USAGE_REPORT
$MAX_JOBS = FlowRC::MAX_JOBS
end
# The flowdir is used in a number of cases to have reasonable
# defaults. Thus it makes some difference if flowdir was
# specified or not:
#
# wd (drmaa_wd)
# The flowdir is used as jobs' default working directory.
# Without flowdir the current working directory is simply
# used. Though each jobs' working directory can also be
# specified within the flowfile, but if they have to that
# would make them harder to read by humans.
#
# out/err/join (drmaa- stdout_path/stderr_path/join)
# Without flowdir "/dev/null" is used as default for 'out'
# and 'join' is true. Reason is there were no better
# default to store job output/error files than the
# current working directory, but if that were used
# it might incidentally happen that masses of job
# output files are dumped in some directory. If flowdir
# was specified at command line it is used as default
# for storing job output and error separately in
# $flowdir/<flowjobname>.o and $flowdir/<flowjobname>.o.
#
# cmd (drmaa_remote_command)
# args (drmaa_argv)
# env (drmaa_env)
$parse_only = false
$drm_depend = false
$flowdir = nil
# command line parsing
while ARGV.length >= 2 do
case ARGV[0]
when "-verify"
$parse_only = true
ARGV.shift
when "-dd"
$drm_depend = true
ARGV.shift
when "-flowdir"
ARGV.shift
usage(1) if $flowdir or ARGV.length < 2
$flowdir = ARGV[0]
ARGV.shift
when "-h", "-help"
usage 0
else
break
end
end
if ARGV.length >= 1
flowfile=ARGV.shift
if ! FileTest.readable?(flowfile)
STDERR.puts flowfile + " does not exit"
exit 1
end
else
usage(1)
end
if ARGV.length == 1
target = parse_flowcall(ARGV.shift)
end
usage(1) unless ARGV.length == 0
# flow parsing and verification
begin
$wd = Dir::getwd
$flowfunction = Hash.new
all = parse_flow(flowfile)
j = $flowfunction[all]
$flowjob = Hash.new
$not_selected = 0
target = parse_flowcall(all) if target.nil?
j.make(all, vars = Hash.new, nil, 0, target)
if $flowjob.size == 0
raise ParsingFormat.new("flow start \"#{target[0]}\" does not exist in #{flowfile}")
end
puts "---+ doing #{$flowjob.size} of #{$flowjob.size+$not_selected} jobs with #{target[0]} as flow target"
STDOUT.flush
exit 0 if $parse_only
rescue ParsingFunction => msg
STDERR.puts "Error in " + msg
exit 1
rescue ParsingFormat => msg
STDERR.puts "Format error: " + msg
exit 1
end
# run the workflow
t1 = Time.now
begin
$terminate_session = $terminate_program = false
trap("INT") { handle_signal }
trap("TERM") { handle_signal }
$session = DRMAA::Session.new
# puts "# ----- submitting jobs"
$already_submitted = $last_submission = 0
$jobs_in_drm = 0
# May not stop reaping before all jobs
# are submitted in case of streaming.
first = true
begin
all_reaped = false
all_submitted = submit_jobs(true)
if first
# puts "# ----- reaping jobs"
first = false
else
if all_submitted
all_reaped = true
else
sleep $STREAMING_RETRY
end
end
reap_jobs()
end until all_reaped
rescue DRMAA::DRMAAException => msg
puts msg
exit 1
end
final_report()
t2 = Time.now
printf("total: %7.1f seconds\n", t2-t1)
exit 0

View File

@ -0,0 +1,46 @@
== Sample flowfiles
The samples comprise four different flowfiles
* tiny.ff (one single job)
* small.ff (29 jobs)
* large.ff (780 jobs)
* huge.ff (>40000 jobs)
== Sample jobs
The flow require a number of job scripts
* do_make
* do_test
* do_inst
* do_uninst
* do_final
* do_report
each of which simply does a sleep.
== Pre-submission procedure
In addition a sample .flowrc.rb file can be found. Besides
a couple of parameters it contains a pre-submission procedure.
== Assumptions according the DRM setup
Note: For running the flows it is necessary to configure
the DRM in a way that
-q gridware.q
-q irix.q
-q solaris.q
-q linux.q
-q darwin.q
and
-P fast (.flowrc.rb)
can be passed as "nat" (i.e. "drmaa_native_specification").
Yet as a matter of course the set-up requirements easily can
be changed, if the sample files are modified accordingly.

View File

@ -0,0 +1,8 @@
#!/bin/sh
me=`basename $0`
echo "# -- args $* -- #"
echo "# -- starting $me -- #"
sleep 1
ret=$?
echo "# -- finished $me -- #"
exit $ret

View File

@ -0,0 +1,8 @@
#!/bin/sh
me=`basename $0`
echo "# -- args $* -- #"
echo "# -- starting $me -- #"
sleep $1
ret=$?
echo "# -- finished $me -- #"
exit $ret

View File

@ -0,0 +1,8 @@
#!/bin/sh
me=`basename $0`
echo "# -- args $* -- #"
echo "# -- starting $me -- #"
sleep 1
ret=$?
echo "# -- finished $me -- #"
exit $ret

View File

@ -0,0 +1,8 @@
#!/bin/sh
me=`basename $0`
echo "# -- args $* -- #"
echo "# -- starting $me -- #"
sleep 1
ret=$?
echo "# -- finished $me -- #"
exit $ret

View File

@ -0,0 +1,8 @@
#!/bin/sh
me=`basename $0`
echo "# -- args $* -- #"
echo "# -- starting $me -- #"
sleep 1
ret=$?
echo "# -- finished $me -- #"
exit $ret

View File

@ -0,0 +1,8 @@
#!/bin/sh
me=`basename $0`
echo "# -- args $* -- #"
echo "# -- starting $me -- #"
sleep $1
ret=$?
echo "# -- finished $me -- #"
exit $ret

View File

@ -0,0 +1,36 @@
# ------------------------------------------------------------------------------------------
ALL = ALLFLOWS | REPORT
ALLFLOWS = FLOW($arch=solaris) & FLOW($arch=linux) & FLOW($arch=irix) & FLOW($arch=darwin)
FLOW = BUILD | INST | TESTS | FINAL
# ------------------------------------------------------------------------------------------
BUILD = { cmd=do_make, nat=-q $arch.q, args= 5 }
INST = { cmd=do_inst, nat=-q gridware.q, args=4 -local -bin $arch, name=I$arch }
TESTS = SEVEN & SEVEN & SEVEN & SEVEN
SEVEN = DAY($day=mon) & DAY($day=tue) & DAY($day=wed) & DAY($day=thu) & DAY($day=fri) & DAY($day=sat) & DAY($day=sun)
DAY = T & T & T & T
T = S1 & S2 & S3 & S4 & S1 & S2 & S3 & S4
S1 = TT1 | TT2 | TT3
S2 = TT1 | TT2 | TT3
S3 = TT1 | TT2 | TT3
S4 = TT1 | TT2 | TT3
TT1 = T1 & T2 & T3 & T4
TT2 = T1 & T2 & T3 & T4
TT3 = T1 & T2 & T3 & T4
TT4 = T1 & T2 & T3 & T4
TT5 = T1 & T2 & T3 & T4
T1 = { cmd=do_test, nat= -q $arch.q, args=1, args=$day }
T2 = { cmd=do_test, nat= -q $arch.q, args=2, args=$day }
T3 = { cmd=do_test, nat= -q $arch.q, args=3, args=$day }
T4 = { cmd=do_test, nat= -q $arch.q, args=4, args=$day }
FINAL = { cmd=do_final, nat=-q $arch.q, name=FIN$arch }
# ------------------------------------------------------------------------------------------
REPORT = LANG($whom=engineering) & LANG($whom=markting) & LANG($whom=sales)
LANG = RR1($lang=ger) & RR2($lang=eng) & RR3($lang=jap)
RR1 = R1($size=1G) | R2($size=2G) | R3($size=4G)
RR2 = R1($size=1G) | R2($size=2G) | R3($size=4G)
RR3 = R1($size=1G) | R2($size=2G) | R3($size=4G)
R1 = R($format=html) & R($format=wiki) & R($format=pdf) & R($format=soffice )
R2 = R($format=html) & R($format=wiki) & R($format=pdf) & R($format=soffice )
R3 = R($format=html) & R($format=wiki) & R($format=pdf) & R($format=soffice )
R = { cmd=do_report, nat=-q gridware.q, args=$lang $size $format }
# ------------------------------------------------------------------------------------------

View File

@ -0,0 +1,21 @@
# ------------------------------------------------------------------------------------------
ALL = FLOW($arch=solaris) & FLOW($arch=linux) & FLOW($arch=irix) & FLOW($arch=darwin)
FLOW = BUILD | INST | TESTS | FINAL
TESTS = T & T & T & T
T = S1 & S2 & S3 & S4
S1 = TT1 | TT2 | TT3
S2 = TT1 | TT2 | TT3
S3 = TT1 | TT2 | TT3
S4 = TT1 | TT2 | TT3
TT1 = T1 & T2 & T3 & T4
TT2 = T1 & T2 & T3 & T4
TT3 = T1 & T2 & T3 & T4
# ------------------------------------------------------------------------------------------
BUILD = { cmd=do_make, nat=-q $arch.q, args=5 }
INST = { cmd=do_inst, nat = -q gridware.q, args=1 -local -bin $arch, name=I$arch }
FINAL = { cmd=do_final, name=FIN$arch, args=1 }
T1 = { cmd=do_test, nat= -q $arch.q, args=1 }
T2 = { cmd=do_test, nat= -q $arch.q, args=2 }
T3 = { cmd=do_test, nat= -q $arch.q, args=3 }
T4 = { cmd=do_test, nat= -q $arch.q, args=4 }
# ------------------------------------------------------------------------------------------

View File

@ -0,0 +1,15 @@
# ------------------------------------------------------------------------------------------
ALL = ALLFLOWS | REPORT
# ------------------------------------------------------------------------------------------
ALLFLOWS = FLOW($arch=darwin) & FLOW($arch=linux) & FLOW($arch=irix) & FLOW($arch=solaris)
FLOW = BUILD | INST | TESTS | FINAL
TESTS = T1 & T2 & T3 & T4
# ------------------------------------------------------------------------------------------
BUILD = { cmd=do_make, nat=-q $arch.q, args=5 }
INST = { cmd=do_inst, nat=-q gridware.q, args=1 -local -bin $arch, name=I$arch }
FINAL = { cmd=do_uninst, nat=-q $arch.q, args=1, name=FIN$arch }
T1 = { cmd=do_test, nat = -q $arch.q, args = 1 }
T2 = { cmd=do_test, nat = -q $arch.q, args = 2 }
T3 = { cmd=do_test, nat = -q $arch.q, args = 3 }
T4 = { cmd=do_test, nat = -q $arch.q, args = 4 }
REPORT = { cmd=do_report }

View File

@ -0,0 +1 @@
TEST = {cmd=do_test, args=-w 15}

66
examples/drmaa/ruby/sig.rb Executable file
View File

@ -0,0 +1,66 @@
#!/usr/bin/ruby
#########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2006
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2006 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
#########################################################################
require 'drmaa'
if ARGV.length < 1
puts "usage: sig.rb <job-path> <args>"
exit 1
end
s = DRMAA::Session.new
t = DRMAA::JobTemplate.new
t.command = ARGV[0]
ARGV.shift
t.arg = ARGV
t.stdout = ":/dev/null"
t.join = true
job = s.run(t)
puts "job: " + job
info = s.wait(job)
if info.wifexited?
puts info.job + " returned with " + info.wexitstatus.to_s
elsif info.wifsignaled?
if info.wcoredump?
puts info.job + " returned died from " + info.wtermsig.to_s + " (core dumped)"
else
puts info.job + " returned died from " + info.wtermsig.to_s
end
elsif info.wifaborted?
puts "aborted: " + info.job
end
info.rusage.each_pair { |name,value| puts "usage " + name + " " + value }

View File

@ -0,0 +1,99 @@
#!/usr/bin/ruby
#########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2006
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2006 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
#########################################################################
require 'drmaa'
class Sleeper < DRMAA::JobTemplate
def initialize
super
self.command = "/bin/sleep"
self.arg = ["1"]
self.stdout = ":/dev/null"
self.join = true
end
end
$terminate_session = $terminate_program = false
def handle_signal
if ! $terminate_session
$terminate_session = true
elsif ! $terminate_program
$terminate_program = true
end
end
trap("INT") { handle_signal }
trap("TERM") { handle_signal }
session = DRMAA::Session.new
# causes DRMAA::Session:run() and DRMAA::Session:run_bulk()
# to sleep and retry in case of DRMAA::DRMAATryAgain.
# That way we implement job streaming.
session.retry = 5
t = Sleeper.new
jobs = Array.new
for i in 1 .. 20 do
job = session.run(t)
puts "job: " + job
jobs << job
break if $terminate_session
end
for i in 1 .. 10
bulk = session.run_bulk(t, 1, 2)
bulk.each { |job| puts "job: " + job }
jobs += bulk
break if $terminate_session
end
while jobs.size > 0 do
info = session.wait_any(1)
if ! info.nil?
if ! info.wifexited?
puts "failed: " + info.job
else
puts info.job + " returned with " + info.wexitstatus.to_s
end
jobs.delete(info.job)
else
if $terminate_program
jobs.clear
elsif $terminate_session
session.terminate
end
end
end
exit 0

View File

@ -0,0 +1,9 @@
#!/bin/sh
./example.rb && ./array.rb && ./sig.rb /bin/sleep 1 && ./stream_and_trap.rb && ./threads.rb && ./attributes.rb
ret=$?
if [ $ret -ne 0 ]; then
echo "##### failed #####"
else
echo "##### success #####"
fi
exit $ret

80
examples/drmaa/ruby/threads.rb Executable file
View File

@ -0,0 +1,80 @@
#!/usr/bin/ruby
#########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2006
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2006 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
#########################################################################
require 'drmaa'
require 'thread'
class Sleeper < DRMAA::JobTemplate
def initialize
super
self.command = "/bin/sleep"
self.arg = ["1"]
self.stdout = ":/dev/null"
self.join = true
end
end
# Submit a bunch of jobs from a number of threads
# and wait for them in main thread.
#
# Note: Ruby threads are not identical with operating
# system threads.
version = DRMAA.version
drm = DRMAA.drm_system
puts "DRMAA #{drm} v #{version}"
session = DRMAA::Session.new
t = Sleeper.new
i = 0
while i<4 do
Thread.start do
j = 0
while j<20 do
puts "job: " + session.run(t)
j += 1
end
end
i += 1
end
session.wait_each{ |info|
job = info.job
if ! info.wifexited?
puts "failed: " + info.job
else
puts info.job + " returned with " + info.wexitstatus.to_s
end
}
exit 0

106
examples/jobs/array_submitter.sh Executable file
View File

@ -0,0 +1,106 @@
#!/bin/sh
#
#___INFO__MARK_BEGIN__
##########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2001
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2001 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
#
# This sample consists of three scripts belonging toghether
#
# array_submitter.sh
# step_A_array_submitter.sh
# step_B_array_submitter.sh
#
# The number <n> passed as an argument to the interactively started
# array_submitter.sh is used to specify the the size of the two array
# jobs step_A_array_submitter.sh/step_B_array_submitter.sh which are
# submitted. Each single job of array job B is not scheduled before
# array job A has not passed the section where qalter is used to release
# the succesor task. Refer to qsub(1) for more information about array
# jobs.
#
# This is a typical scenario in DCC industry where schemes like this
# are used to control sequence of large rendering jobs.
# Note that it is necessary that all hosts where A jobs are started
# must be submit hosts to allow the qalter happen.
#
#$ -S /bin/sh
if [ x$SGE_ROOT = x ]; then
SGE_ROOT=/usr/SGE
fi
if [ ! -d $SGE_ROOT ]; then
echo "error: SGE_ROOT directory $SGE_ROOT does not exist"
exit 1
fi
ARC=`$SGE_ROOT/util/arch`
QSUB=$SGE_ROOT/bin/$ARC/qsub
QALTER=$SGE_ROOT/bin/$ARC/qalter
if [ ! -x $QSUB ]; then
echo "error: cannot execute qsub command under $QSUB"
exit 1
fi
if [ ! -x $QALTER ]; then
echo "error: cannot execute qalter command under $QALTER"
exit 1
fi
tasks=0
while [ "$1" != "" ]; do
case "$1" in
[0-9]*)
tasks=$1
shift
;;
esac
done
if [ $tasks = 0 ]; then
echo "usage: array_submitter.sh <number_of_tasks>"
exit 1
fi
# submit step A jobarray
jobid_a=`$QSUB -t 1-$tasks -r y -N StepA $SGE_ROOT/examples/jobs/step_A_array_submitter.sh | cut -f3 -d" "|cut -f1 -d.`
echo "submission result: jobid_a = $jobid_a"
# submit step B jobarray with hold state
jobid_b=`$QSUB -t 1-$tasks -h -r y -N StepB $SGE_ROOT/examples/jobs/step_B_array_submitter.sh | cut -f3 -d" "|cut -f1 -d.`
echo "submission result: jobid_b = $jobid_b"
# put jobid of step B into context of step A
$QALTER -ac succ=$jobid_b $jobid_a

36
examples/jobs/env-tester.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/sh
#$ -S /bin/sh
#___INFO__MARK_BEGIN__
##########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2001
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2001 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
echo ------------------------------------
env
echo ------------------------------------

View File

@ -0,0 +1,77 @@
#!/bin/sh
#
#
#___INFO__MARK_BEGIN__
##########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2001
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2001 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
QSUB=$SGE_ROOT/bin/$ARC/qsub
name_base=Net
hold=""
jobs=5
while [ "$1" != "" ]; do
case "$1" in
-N)
shift
name_base=$1
shift
;;
-h)
hold=-h
shift
;;
[0-9]*)
jobs=$1
shift
;;
esac
done
echo "going to submit $jobs jobs"
jobid=0
REQUEST=""
i=1
while [ $i -le $jobs ]; do
if [ $i -ne 1 ]; then
opt="-hold_jid $jobid"
fi
jobid=`$QSUB $REQUEST -r y -N $name_base$i $hold $opt $SGE_ROOT/examples/jobs/sleeper.sh 10 | cut -f3 -d" "`
if [ $i -ne 1 ]; then
echo submitted job \#$i name = $name_base$i with jobid $jobid and $opt
else
echo submitted job \#$i name = $name_base$i with jobid $jobid
fi
i=`expr $i + 1`
done

View File

@ -1,81 +0,0 @@
#!/bin/bash
#############################################################
# This example produces a very simple plot and #
# saves it as Matlab figure file and as PNG file #
#############################################################
#############################################################
# set qsub options #
#############################################################
# run in low.q
#$ -l low
# request enough memory
#$ -l h_vmem=8G,memory=8G,h_stack=8M
# request 1 matlab license.
#$ -l matlab=1
# Name the job 'Matlab'
#$ -N Matlab
# send e-mail after job has finished
# use the -M option to define your e-mail address
# #$ -M meine-email@example.org
#$ -m e
# join stdout and stderr in one file
#$ -j y
#############################################################
# output hostname and date (comment out if not needed) #
#############################################################
echo "Runnning Matlab on host " `hostname`
echo "Starting Matlab at " `date`
#############################################################
# launch matlab #
#############################################################
# run non-interactive Matlab session
# use no display (-nodisplay)
# don't show splash screen at startup (-nosplash)
# don't start the matlab desktop (-nodesktop)
# use software opengl (-softwareopengl)
# only use single threaded computations (limit to use of 1 core, -singleCompThread)
# execute all matlab commands between '<< END' and matching 'END'
# Don't forget to add 'exit' and 'END' after replacing
# the commands with your own!
/opt/matlab/bin/matlab -nodisplay -nosplash -nodesktop -softwareopengl -singleCompThread << END
% get environment variable JOB_ID
jobid=str2num(getenv('JOB_ID'));
if isempty(jobid)
jobid = 0;
end
% create filenames for the figure
filename=sprintf('matlab_figure_%d', jobid);
% create new empty figure and save figure handle
fh = figure();
% draw plot
plot(-pi:0.01:pi, sin(-pi:0.01:pi));
% save figure as matlab figure and PNG
saveas(fh, filename, 'fig');
saveas(fh, filename, 'png');
% EXIT MATLAB
exit;
END
#############################################################
# output date (comment out if not needed) #
#############################################################
echo "Matlab finnished at " `date`

View File

@ -0,0 +1 @@
../../local/examples/jobs/matlab_script.sh

View File

@ -0,0 +1 @@
../../local/examples/jobs/ompi_connectivity.sh

1
examples/jobs/ompi_hello.sh Symbolic link
View File

@ -0,0 +1 @@
../../local/examples/jobs/ompi_hello.sh

1
examples/jobs/ompi_ring.sh Symbolic link
View File

@ -0,0 +1 @@
../../local/examples/jobs/ompi_ring.sh

107
examples/jobs/pascal.sh Executable file
View File

@ -0,0 +1,107 @@
#!/bin/sh
#
#___INFO__MARK_BEGIN__
##########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2001
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2001 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
#
# This is a sample script to demonstrate use of job dependencies. The
# sample submits one job for each node in the pascal triangle:
#
# 1 depth 1
# / \
# 1 1 depth 2
# / \ / \
# 1 2 1 depth 3
# / \ / \ / \
# 1 3 3 1 depth 4
#
# : : : :
#
# Data exchange between jobs is done via files in jobnet_dir.
#
# Usage: pascal.sh <depth of pascal triangle>
jobnet_dir=$HOME/pascal_jobnet
if [ $# -ne 1 ]; then
echo "usage: pascal.sh <depth of pascal triangle>" >&2
exit 1
fi
n=$1
i=1
mkdir $jobnet_dir
rm $jobnet_dir/*
while [ $i -le $n ]; do
j=1
while [ $j -le $i ]; do
prev_line=`expr $i - 1`
# specify own jobname
submit_args="-N P${i}_${j}"
if [ $j -gt 1 -a $j -lt $i ]; then
depend1=P${prev_line}_`expr ${j} - 1`
depend2=P${prev_line}_${j}
depend="$depend1 $depend2"
submit_args="$submit_args -hold_jid $depend1,$depend2"
elif [ $j -gt 1 ]; then
depend=P${prev_line}_`expr ${j} - 1`
submit_args="$submit_args -hold_jid $depend"
elif [ $j -lt $i ]; then
depend=P${prev_line}_${j}
submit_args="$submit_args -hold_jid $depend"
fi
echo "qsub -j y -o $jobnet_dir $submit_args -- $jobnet_dir $depend"
qsub -r y -j y -o $jobnet_dir $submit_args -- $jobnet_dir $depend << EOF
#!/bin/sh
#$ -S /bin/sh
result=0
jobnet_dir=\$1
shift
while [ \$# -gt 0 ]; do
depend=\$1
shift
to_add=\`cat \$jobnet_dir/DATA_\$depend\`
result=\`expr \$result + \$to_add\`
echo "\$REQUEST: adding \$to_add found in \$jobnet_dir/DATA_\$depend results in \$result"
done
if [ \$result = 0 ]; then
result=1
fi
echo \$result > \$jobnet_dir/DATA_\$REQUEST
EOF
j=`expr $j + 1`
done
i=`expr $i + 1`
done

View File

@ -1,75 +0,0 @@
#!/bin/bash
# This job script takes a nap for 10 seconds (or paramter $2) every 30 minutes (or paramter $1)
# SGE options
#$ -N PSleeper
#$ -l scf=1M,mem=100M,h_vmem=100M
#$ -q normal.q
#$ -cwd
# process args
case "$1" in
-h)
echo "usage: $0 [-h | [-d] [T] [nap]]"
echo "periodically take a nap"
echo ""
echo "-h print this help and exit"
echo "-d print debug info"
echo "T take a nap every T minutes (default: 30)"
echo "nap take a nap for nap seconds (default: 10)"
exit 1
;;
*)
debug=0
terse="-terse"
debug_flag=""
do_echo=0
T=30
nap=10
while (( "$#" )); do
case "$1" in
-d)
debug=1
terse=""
debug_flag="-d"
do_echo=1
;;
*)
T=${1:-30}
nap=${2:-10}
break
;;
esac
shift
done
;;
esac
# set other variables
next=$(date -d "${T} minutes" +%Y%m%d%H%M)
script=/opt/SGE/examples/jobs/periodic_sleeper.sh
# output some informations
if [ ${debug} -eq 1 ]; then
echo "T = ${T}, nap=${nap}"
echo "next run at ${next} (YYYYMMDDhhmm)"
echo "debug_flag = ${debug_flag}, do_echo = ${do_echo}"
echo ""
fi
# commands to run in Grid Engine
/opt/SGE/examples/jobs/sleeper.sh ${nap} ${do_echo}
# re-submit script to execute in T minutes
jobid=$(qsub ${terse} -a ${next} ${script} ${debug_flag} ${T} ${nap})
exit_code=$?
if [ ${debug} -eq 1 ]; then
echo "${jobid}"
fi
if [ ${exit_code} -ne 0 ]; then
if [ ${debug} -eq 1 ]; then
echo "${jobid}"
echo "Ups, something went wrong, check output!"
fi
exit ${exit_code}
fi

View File

@ -0,0 +1 @@
../../local/examples/jobs/periodic_sleeper.sh

79
examples/jobs/pminiworm.sh Executable file
View File

@ -0,0 +1,79 @@
#!/bin/sh
#___INFO__MARK_BEGIN__
##########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2001
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2001 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
#
#
# -------------------------------------------
# -- use Bourne shell --
#$ -S /bin/sh
# -- our name --
#$ -N PMiniWorm
# -------------------------------------------
# -- send mail if the job exits abnormally --
#$ -m a
# -------------------------------------------
# -- What to redirect to where --
#$ -e /dev/null
#$ -o /dev/null
QSUB=$SGE_ROOT/bin/$ARC/qsub
SLEEP=120
echo using $QSUB as qsub command
if [ "$1" = "" ]; then
arg=1
else
arg=`expr $1 + 1`
fi
NAME=W$arch$arg
# started by SGE or manually
if [ "$JOB_ID" = "" ]; then
echo "submitting $NAME"
else
sleep $SLEEP
fi
# first try
# cmd="$QSUB -N $NAME -l arch=$arch $SGE_ROOT/examples/jobs/pminiworm.sh $arg"
cmd="$QSUB -N $NAME $SGE_ROOT/examples/jobs/pminiworm.sh $arg"
$cmd
# repeat until success
while [ "x$?" != "x0" ]; do
echo "pminiworm.sh: qsub failed - retrying .." >&2
sleep $SLEEP
$cmd
done

47
examples/jobs/simple.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/sh
#
#
#___INFO__MARK_BEGIN__
##########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2001
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2001 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
# This is a simple example of a SGE batch script
# request Bourne shell as shell for job
#$ -S /bin/sh
#
# print date and time
date
# Sleep for 20 seconds
sleep 20
# print date and time again
date

View File

@ -1,37 +0,0 @@
#! /bin/bash
#############################################################
# This example show a list of availabel conda environments #
#############################################################
#############################################################
# set qsub options #
#############################################################
# run in low.q
#$ -l low
# request enough memory
# #$ -l h_vmem=8G,memory=8G,h_stack=8M
# Name the job 'Conda-Test'
#$ -N Conda-Test
#############################################################
# initialize conda #
#############################################################
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/opt/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
#############################################################
# show conda environments #
#############################################################
conda env list

View File

@ -0,0 +1 @@
../../local/examples/jobs/simple_conda_test.sh

63
examples/jobs/sleeper.sh Executable file
View File

@ -0,0 +1,63 @@
#!/bin/sh
#
#___INFO__MARK_BEGIN__
##########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2001
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2001 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
#
# Usage: sleeper.sh [time [do_echo]]
# default for time is 60 seconds
# default for do_echo is 1 (=true)
#
# -- our name ---
#$ -N Sleeper
#$ -S /bin/sh
time=60
do_echo=1
if [ $# -ge 1 ]; then
time=$1
fi
if [ $# -ge 2 ]; then
do_echo=$2
fi
if [ $do_echo -ne 0 ]; then
/bin/echo Here I am: `hostname`. Sleeping now at: `date`
fi
sleep $time
if [ $do_echo -ne 0 ]; then
echo Now it is: `date`
fi

187
examples/jobs/ssession.sh Executable file
View File

@ -0,0 +1,187 @@
#!/bin/sh
#$ -S /bin/sh
#$ -pe make 1
#$ -N SSession
#$ -v PATH
#___INFO__MARK_BEGIN__
##########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2001
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2009 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
ARCH=`$SGE_ROOT/util/arch`
ECHO="$SGE_ROOT/utilbin/$ARCH/echo_raw -e"
ssession_logging_enabled="false" # is logging enabled?
ssession_logfile="/tmp/ssession.log" # logfile
tfile="taskfile.txt" # default taskfile name if not other specified
mfile="" # makefile name
isource="tfile" # type of onput "tfile" or "mfile"
ssession_show_usage()
{
echo "usage: ssession [ taskfile | -mf makefile ]"
echo
echo " If there is neither a taskfile nor a makefile specified then"
echo " this script assumes that there is taskfile named taskfile.txt"
echo " in the current working directory."
echo
echo " taskfile - taskfile containing the tasks to be executed in the session"
echo " makefile - makefile containing the tasks an depedency definition"
}
# add start rule to makefile
ssession_makefile_add_all()
{
taskfile=$1
makefile=$2
start="all:"
line_i=1
max=`wc -l $taskfile|cut -c 1-8`
while [ $line_i -le $max ]; do
line=`head -$line_i $taskfile | tail -1`
start=`echo $start task${line_i}`
line_i=`expr $line_i + 1`
done
echo $start >>$makefile
echo "" >>$makefile
unset makefile
unset start
unset line_i
}
# add one rule for each task in taskfile
ssession_makefile_add_task()
{
taskfile=$1
makefile=$2
line_i=1
max_lines=`wc -l $taskfile|cut -c 1-8`
while [ $line_i -le $max_lines ]; do
command=`head -$line_i $taskfile | tail -1`
echo "task${line_i}:" >>$makefile
$ECHO "\t${command}" >>$makefile
echo "" >>$makefile
line_i=`expr $line_i + 1`
done
unset max_lines
unset taskfile
unset makefile
unset line_i
}
# create the makefile
ssession_makefile_create()
{
makefile=$1
if [ -f $makefile ]; then
rm -f $makefile
echo rm
fi
touch $makefile
unset makefile
}
# destroy the taskfile
ssession_makefile_destroy()
{
makefile=$1
# rm -f $makefile
unset makefile
}
# start a qmake job that executes tasks in taskfile
ssession_start_qmake()
{
makefile=$1
qmake -inherit -- -f $makefile
}
ssession_log()
{
if [ $ssession_logging_enabled = true ]; then
echo "$@" >>$ssession_logfile
fi
}
if [ $# = 1 ]; then
if [ -f "$1" ]; then
tfile="$1"
else
ssession_show_usage
exit
fi
elif [ $# = 2 ]; then
if [ "$1" = "-mf" ]; then
mfile="$2"
isource="mfile"
else
ssession_show_usage
exit
fi
else
tfile="taskfile.txt"
fi
if [ "$mfile" = "" ]; then
if [ -d "$TMPDIR" ]; then
mfile="${TMPDIR}/Makefile.$$"
else
mfile="/tmp/Makefile.$$"
fi
fi
if [ "$isource" = "tfile" ]; then
ssession_log "Using taskfile \"$tfile\""
ssession_log "Creating makefile \"$mfile\""
ssession_makefile_create $mfile
ssession_makefile_add_all $tfile $mfile
ssession_makefile_add_task $tfile $mfile
ssession_start_qmake $mfile
ssession_makefile_destroy $mfile
else
ssession_log "Using makefile \"$mfile\""
ssession_start_qmake $mfile
fi

View File

@ -0,0 +1,47 @@
#!/bin/sh
#
#
#___INFO__MARK_BEGIN__
##########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2001
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2001 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
# request "/bin/sh" as shell for job
#$ -S /bin/sh
QSTAT=$SGE_ROOT/bin/$ARC/qstat
QALTER=$SGE_ROOT/bin/$ARC/qalter
# find out successor jobid
# must be set by submission script
successor=`$QSTAT -j $JOB_ID | grep context |cut -f2 -d=`
# release appropriate succesor task
$QALTER -h U $successor.$SGE_TASK_ID

View File

@ -0,0 +1,39 @@
#!/bin/sh
#
#
#___INFO__MARK_BEGIN__
##########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2001
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2001 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
# request "/bin/sh" as shell for job
#$ -S /bin/sh
echo $JOB_ID.$SGE_TASK_ID

79
examples/jobs/worker.sh Executable file
View File

@ -0,0 +1,79 @@
#!/bin/sh
#
#
#___INFO__MARK_BEGIN__
##########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2001
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2001 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
#
# Usage: worker.sh [[time [nprocs] [ntimes] [work_parameter]]]
# default for time is 120 seconds
# default for nprocs is 1
# default for work_parameter is ""
# request "bin/sh" as shell for job
#$ -S /bin/sh
trap "echo 'got sigxcpu'" 24
time=120
procs=1
ntimes=1
wparam=""
if [ $# -ge 1 ]; then
time=$1
fi
if [ $# -ge 2 ]; then
procs=$2
fi
if [ $# -ge 3 ]; then
ntimes=$3
fi
if [ $# -ge 4 ]; then
wparam=$4
fi
echo "Doing this $ntimes times"
if [ ! -x /usr/lib/gridengine//work ]; then
echo "worker.sh: can't execute /usr/lib/gridengine/work" >&2
exit 1
fi
while [ $ntimes != '0' ]; do
ntimes=`expr $ntimes - 1`
echo "Running $time seconds"
echo "Using $procs processes"
/usr/lib/gridengine//work -f $procs -w $time $wparam &
done
wait

1
examples/jobsbin Symbolic link
View File

@ -0,0 +1 @@
/usr/lib/gridengine

1
flex-grid/cache Symbolic link
View File

@ -0,0 +1 @@
/rscratch/minos19/flex_grid_cache

View File

@ -0,0 +1,33 @@
<?xml version="1.0"?>
<qlicserverConfig>
<parameters type="overwrite">
<param name="lmutil">/opt/SGE/flex-grid/scripts/abaqus_lmutil</param>
<!-- <param name="LM_LICENSE_FILE">27000@abaqus-lizenz.rz.ruhr-uni-bochum.de</param> -->
<param name="LM_LICENSE_FILE">27000@vmrz0300.vm.ruhr-uni-bochum.de</param>
<param name="dir">/opt/SGE/flex-grid/cache</param>
<param name="output">qlicserver_abaqus.xml</param>
</parameters>
<!--
| Map resource names (complexes) to values (features)
| served by the license manager(s).
| Resources without a "served" attribute are considered internal
| Resources with type "track" are reported but not managed
| The urgency is how much extra weight to give to particular resources.
| If a 'slot' is weighted with 1000, we can give an extra 10% to
| a few resources. [Format: INTEGER]
|
| The resource 'limit' specifies an upper limit to prevent applications
| from flooding the cluster and/or prevent jobs from consuming all the
| available licenses. A negative limit is subtracted from the total
| to obtain the limit. [Format: INTEGER]
|
| Derived resources are combined from sub-elements and inherit the
| limits from their sub-elements.
|
| Resources that are not served and not derived are internal resources
+ -->
<resources type="overwrite">
<resource name="abaqus" served="abaqus" limit="30" type="job"/>
<resource name="cae" served="cae" limit="2" type="job"/>
</resources>
</qlicserverConfig>

View File

@ -0,0 +1,31 @@
<?xml version="1.0"?>
<qlicserverConfig>
<parameters type="overwrite">
<param name="lmutil">/opt/matlab/etc/glnxa64/lmutil</param>
<param name="LM_LICENSE_FILE">/opt/SGE/flex-grid/licenses/comsol.lic</param>
<param name="dir">/opt/SGE/flex-grid/cache</param>
<param name="output">qlicserver_comsol.xml</param>
</parameters>
<!--
| Map resource names (complexes) to values (features)
| served by the license manager(s).
| Resources without a "served" attribute are considered internal
| Resources with type "track" are reported but not managed
| The urgency is how much extra weight to give to particular resources.
| If a 'slot' is weighted with 1000, we can give an extra 10% to
| a few resources. [Format: INTEGER]
|
| The resource 'limit' specifies an upper limit to prevent applications
| from flooding the cluster and/or prevent jobs from consuming all the
| available licenses. A negative limit is subtracted from the total
| to obtain the limit. [Format: INTEGER]
|
| Derived resources are combined from sub-elements and inherit the
| limits from their sub-elements.
|
| Resources that are not served and not derived are internal resources
+ -->
<resources type="overwrite">
<resource name="comsol" served="COMSOL" type="job"/>
</resources>
</qlicserverConfig>

View File

@ -0,0 +1,36 @@
<?xml version="1.0"?>
<qlicserverConfig>
<parameters type="overwrite">
<param name="lmutil">/opt/matlab/etc/glnxa64/lmutil</param>
<param name="LM_LICENSE_FILE">/opt/SGE/flex-grid/licenses/multiphysics.lic</param>
<param name="dir">/opt/SGE/flex-grid/cache</param>
<param name="output">qlicserver_local.xml</param>
<param name="qhost">qhost.xml</param>
<param name="qstat">qstat.xml</param>
</parameters>
<!--
| Map resource names (complexes) to values (features)
| served by the license manager(s).
| Resources without a "served" attribute are considered internal
| Resources with type "track" are reported but not managed
| The urgency is how much extra weight to give to particular resources.
| If a 'slot' is weighted with 1000, we can give an extra 10% to
| a few resources. [Format: INTEGER]
|
| The resource 'limit' specifies an upper limit to prevent applications
| from flooding the cluster and/or prevent jobs from consuming all the
| available licenses. A negative limit is subtracted from the total
| to obtain the limit. [Format: INTEGER]
|
| Derived resources are combined from sub-elements and inherit the
| limits from their sub-elements.
|
| Resources that are not served and not derived are internal resources
resource name="hyper" served="GridWorks" type="job"
<resource name="matlab" served="MATLAB" type="job" limit="-2"/>
<resource name="signal_toolbox" served="Signal_Toolbox" type="job" limit="-2"/>
+ -->
<resources type="overwrite">
<resource name="femlab" served="COMSOL" type="track"/>
</resources>
</qlicserverConfig>

View File

@ -0,0 +1,32 @@
<?xml version="1.0"?>
<qlicserverConfig>
<parameters type="overwrite">
<param name="lmutil">/opt/matlab/etc/glnxa64/lmutil</param>
<param name="LM_LICENSE_FILE">/opt/SGE/flex-grid/licenses/matlab.lic</param>
<param name="dir">/opt/SGE/flex-grid/cache</param>
<param name="output">qlicserver_matlab.xml</param>
</parameters>
<!--
| Map resource names (complexes) to values (features)
| served by the license manager(s).
| Resources without a "served" attribute are considered internal
| Resources with type "track" are reported but not managed
| The urgency is how much extra weight to give to particular resources.
| If a 'slot' is weighted with 1000, we can give an extra 10% to
| a few resources. [Format: INTEGER]
|
| The resource 'limit' specifies an upper limit to prevent applications
| from flooding the cluster and/or prevent jobs from consuming all the
| available licenses. A negative limit is subtracted from the total
| to obtain the limit. [Format: INTEGER]
|
| Derived resources are combined from sub-elements and inherit the
| limits from their sub-elements.
|
| Resources that are not served and not derived are internal resources
+ -->
<resources type="overwrite">
<resource name="matlab" served="MATLAB" type="job" limit="100"/>
<resource name="mcc" served="Compiler" type="job" limit="100"/>
</resources>
</qlicserverConfig>

View File

@ -0,0 +1,31 @@
<?xml version="1.0"?>
<qlicserverConfig>
<parameters type="overwrite">
<param name="lmutil">/opt/matlab/etc/glnxa64/lmutil</param>
<param name="LM_LICENSE_FILE">/opt/SGE/flex-grid/licenses/matlab.lic</param>
<param name="dir">/opt/SGE/flex-grid/cache</param>
<param name="output">qlicserver_trelis.xml</param>
</parameters>
<!--
| Map resource names (complexes) to values (features)
| served by the license manager(s).
| Resources without a "served" attribute are considered internal
| Resources with type "track" are reported but not managed
| The urgency is how much extra weight to give to particular resources.
| If a 'slot' is weighted with 1000, we can give an extra 10% to
| a few resources. [Format: INTEGER]
|
| The resource 'limit' specifies an upper limit to prevent applications
| from flooding the cluster and/or prevent jobs from consuming all the
| available licenses. A negative limit is subtracted from the total
| to obtain the limit. [Format: INTEGER]
|
| Derived resources are combined from sub-elements and inherit the
| limits from their sub-elements.
|
| Resources that are not served and not derived are internal resources
+ -->
<resources type="overwrite">
<resource name="trelis" served="TRELIS" type="job"/>
</resources>
</qlicserverConfig>

View File

@ -0,0 +1 @@
/opt/comsol53a/multiphysics/license/license.dat

View File

@ -0,0 +1,2 @@
SERVER kamikaze 80b660b0 7788
USE_SERVER

2
flex-grid/licenses/ifort.lic Executable file
View File

@ -0,0 +1,2 @@
SERVER kamikaze 80b660b0 28518
USE_SERVER

View File

@ -0,0 +1 @@
/opt/matlab/licenses/01network.lic

View File

@ -0,0 +1,2 @@
SERVER phaidra.geophysik.ruhr-uni-bochum.de 00163ef90680 1718
USE_SERVER

View File

@ -0,0 +1,221 @@
#!/bin/sh
#
# Snapshot of the current GridEngine configuration using git for the
# backend storage and tracking mechanism.
#
# Should normally be called via a cronjob.
#
# Following Edward Dale's idea:
# http://scompt.com/blog/archives/2009/10/13/versioned-grid-engine-configuration
# but using git for the backend
#
# initialize:
#
# git --git-dir=$GIT_DIR init --bare --shared=world
#
# Note: we use Perl for inplace editing since some versions of sed have
# problems with this task.
################################################################################
################################################################################
# CUSTOMIZE THESE SETTINGS TO MATCH YOUR REQUIREMENTS:
SGE_ROOT=/opt/grid
SGE_CELL=default
GIT_DIR=/data/cfd/share/git-repo/gridengine-config.git
#
# END OF CUSTOMIZE SETTINGS
################################################################################
################################################################################
Script=${0##.*/}
saveScript="$SGE_ROOT/util/upgrade_modules/save_sge_config.sh"
export SGE_ROOT SGE_CELL GIT_DIR
for i in git perl
do
type $i >/dev/null 2>&1 || {
echo "Error: $Script - no '$i' found"
exit 1
}
done
#------------------------------------------------------------------------------
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: ${0##*/} [OPTION | GIT_COMMAND]
options:
-help display this usage
init initialize git repo in $GIT_DIR
pass-through git commands:
log ls-files
show whatchanged
Snapshot of the current GridEngine configuration using git for the
backend storage and tracking mechanism.
* git repository stored here:
$GIT_DIR
copyright (c) 2009-10 <Mark.Olesen@faurecia.com>
USAGE
exit 1
}
#------------------------------------------------------------------------------
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
( help | -h | -help )
usage
;;
( init )
shift
if [ -d "$GIT_DIR" ]
then
echo "Error: $Script - $GIT_DIR already exists"
exit 1
else
git --git-dir=$GIT_DIR init --bare --shared=world $@
rc=$?
# add a description for gitweb
i="$GIT_DIR/description"
if [ -f "$i" -a -w "$i" ]
then
echo "snapshot of the current GridEngine configuration" > $i
fi
fi
exit $rc
;;
( log | ls-files | show | whatchanged )
git --git-dir=$GIT_DIR $@
exit $?
;;
(*)
usage "unknown option/argument: '$*'"
;;
esac
done
[ -d "$GIT_DIR" ] || {
echo "git repo: $GIT_DIR does not exist"
exit 1
}
i="$SGE_ROOT/$SGE_CELL/common/settings.sh"
if [ -f "$i" -a -r "$i" ]
then
. "$i"
else
echo "cannot read $i"
exit 1
fi
[ -f "$saveScript" -a -r "$saveScript" ] || {
echo "cannot read $i"
exit 1
}
# Create a fresh empty directory
# cannot use --tmpdir on older systems
tmpDir=$(mktemp -d "/tmp/sgeSaveConfig.XXXXXXXXXX")
trap "rm -rf $tmpDir 2>/dev/null; exit 0" EXIT TERM INT
[ -d "$tmpDir" ] || {
echo "Error: temp dir '$tmpDir' does not exist"
exit 1
}
$saveScript $tmpDir
#------------------------------------------------------------------------------
# cleanup
#
(
cd $tmpDir || exit 1
# all operations are now in the current directory
GIT_WORK_TREE=.
export GIT_WORK_TREE
# minor error checking that the save script worked
if [ -f backup_date -a -r backup_date ]
then
msg=$(cat backup_date)
else
echo "cannot read backup_date - $saveScript might have failed"
exit 1
fi
# ignore accounting (too big)
rm -f cell/accounting
# ignore current users
rm -f users/*
# ignore current load_values for exec hosts
perl -i -ne '/^load_values/ or print' execution/*
# assign (consumable) complex_values to zero - otherwise we indirectly
# track the external license usage when qlicserver is being used
# also sort the complexes to avoid spurious changes
perl -i -p -e 'if (/^complex_values/) { chomp; ' \
-e 's/=\d+/=0/g; s/^(complex\S+\s+)//; ' \
-e '$_ = $1 . join("," => sort split /,/) . "\n" }' \
execution/global
#
# determine if the configuration changed
#
# this is fairly roundabout until we find a better way
needsCommit=false
if [ -n "$(git ls-files -d)" ] # files deleted?
then
needsCommit=true
elif [ -n "$(git ls-files -o)" ] # files added?
then
needsCommit=true
else
# files modified?
# do it the long way to ensure we also get staged modifications
set -- $(git status | perl -ne 's/^#\s+modified:// and print')
# changes in backup_date, jobseqnum etc alone are not enough
# to warrant a commit
while [ "$#" -ge 1 ]
do
case $1 in
( arseqnum | backup_date | jobseqnum )
shift
;;
(*)
needsCommit=true
break
;;
esac
done
fi
if [ "$needsCommit" = true ]
then
# register all new files
git add .
# commit everything
git commit -a -m "$msg"
else
echo "no changes to be committed $msg"
fi
)
exit 0
#------------------------------------------------------------------------------

View File

@ -0,0 +1,5 @@
#!/bin/sh
# $Id: abaqus_lmutil 180 2010-09-17 15:46:41Z kasper $
/opt/abaqus/Commands/abaqus licensing lmstat -a -f abaqus -S ABAQUSLM
/opt/abaqus/Commands/abaqus licensing lmstat -a -f cae -S ABAQUSLM

View File

@ -0,0 +1,124 @@
#!/usr/bin/perl -w
use strict;
use Getopt::Std qw( getopts );
use Time::Local qw( timelocal );
my ($releaseDate) = qw( 2009-10-02 );
( my $Script = $0 ) =~ s{^.*/}{};
# -------------------------------------------------------------------------
sub usage {
$! = 0; # clean exit
warn "@_\n" if @_;
die <<"USAGE";
usage:
$Script [OPTION] file1 [ .. fileN ]
with options:
-b YYYY[-MM[-DD]]
begin date for accounting (job end_time > DATE 2 A.M.)
-e YYYY[-MM[-DD]]
end date for accounting (job end_time <= DATE 2 A.M.)
-h usage
Extract portions of the GridEngine accounting(5) file according to the
job end_time. For example,
$Script -b 2008-01-01 -e 2009 ...
extracts the accounting for jobs that finished running in 2008.
The value of 2 A.M. avoids problems that daylight savings time might
otherwise cause.
version ($releaseDate)
copyright (c) 2009 <Mark.Olesen\@faurecia.com>
Licensed and distributed under the Creative Commons
Attribution-NonCommercial-ShareAlike 3.0 License.
http://creativecommons.org/licenses/by-nc-sa/3.0
USAGE
}
# -------------------------------------------------------------------------
my %opt;
getopts( "hb:e:", \%opt ) or usage();
usage() if $opt{h};
@ARGV or usage();
for (@ARGV) {
-f $_ or die "no file '$_'\n";
## handle compressed files transparently
if (/\.bz2$/) {
$_ = qq{bzip2 -dc "$_"|};
}
elsif (/\.gz$/) {
$_ = qq{gzip -dc "$_"|};
}
}
for (qw( b e )) {
if ( $opt{$_} ||= 0 ) {
my ( $yy, $mm, $dd );
if ( $opt{$_} =~ /^(\d{2,4})-(\d{1,2})-(\d{1,2})$/ ) {
## YYYY-MM-DD
( $yy, $mm, $dd ) = ( $1, $2, $3 );
}
elsif ( $opt{$_} =~ /^(\d{2,4})-(\d{1,2})$/ ) {
## YYYY-MM
( $yy, $mm ) = ( $1, $2 );
}
elsif ( $opt{$_} =~ /^(\d{2,4})$/ ) {
## YYYY
($yy) = ($1);
}
else {
usage("invalid date format: '$opt{$_}'");
}
# treat missing month/day as '1'
$mm ||= 1;
$dd ||= 1;
# convert from YYYY-MM-DD to epoch,
# start at 2am - avoid problems with daylight savings time
$opt{$_} = timelocal( 0, 0, 2, $dd, $mm - 1, $yy ); # month (0..11)
}
}
$opt{b} or $opt{e} or usage("must specify at least one of -b or -e");
if ( $opt{e} and $opt{b} >= $opt{e} ) {
usage("-b DATE must less than -e DATE");
}
my $fileCount;
while (<>) {
if (/^\s*#/) {
## pass-thru comments, but only for the first file
print unless $fileCount;
next;
}
my ($endtime) = ( split /:/ )[10];
# only allow things that ran (endtime non-zero)
# and that are within the filter limits
if ( $endtime
and ( $opt{b} ? ( $endtime > $opt{b} ) : 'okay' )
and ( $opt{e} ? ( $endtime <= $opt{e} ) : 'okay' ) )
{
print;
}
}
continue {
$fileCount++ if eof;
}
__END__
FORMAT - see accounting(5)
08 submission_time
09 start_time
10 end_time

517
flex-grid/scripts/qlic Executable file
View File

@ -0,0 +1,517 @@
#!/usr/bin/perl -w
use strict;
use Getopt::Std qw( getopts );
use POSIX qw( );
( my $Script = $0 ) =~ s{^.*/}{};
my $time = time;
my $date = POSIX::strftime( "%F %T", localtime $time );
$ENV{SGE_ROOT} or die "Error $Script: \$SGE_ROOT is not set\n";
$ENV{SGE_CELL} ||= "default"; # sge_cell
my ($siteLocation) = join "/" => ( $ENV{SGE_ROOT}, $ENV{SGE_CELL}, "site" );
my $config = {
-site => ( $siteLocation || '' ),
-cache => ( $siteLocation || '' ) . "/cache/" . "qlicserver.xml",
-limits => ( $siteLocation || '' ) . "/" . "qlicserver.limits",
};
# ------------------------------------------------------------------------
# utils
#
# calculate age from an epoch value
#
sub age {
my ( $a, $b ) = @_;
my $diff = ( $a - $b );
my $sign = '';
if ( $diff < 0 ) { # handle negatives
$sign = '-';
$diff = abs($diff);
}
sprintf "$sign%d:%02d:%02d", # format into hh:mm:ss
( int $diff / 3_600 ), # hh
( ( int $diff / 60 ) % 60 ), # mm
( $diff % 60 ); # ss
}
#
# change hash references to a comma-delimited string of key=value entries
#
sub hashRefToString {
map {
my $ref = $_;
ref $ref ? map { "$_=$ref->{$_}" } sort keys %$ref : ()
} @_;
}
#
# extract attrib="value" ... attrib="value"
#
sub parseXMLattrib {
my $str = shift || '';
my %attr;
while ($str =~ s{^\s*(\w+)=\"([^\"]*)\"}{}s
or $str =~ s{^\s*(\w+)=\'([^\']*)\'}{}s )
{
$attr{$1} = $2;
}
%attr;
}
# ------------------------------------------------------------------------
# processing of qlicserver.xml output
#
package qlicCache;
sub new {
my $caller = shift;
my $file = shift;
my $self = bless {
( map { $_ => {} } qw( -rc ) ),
( map { $_ => '' } qw( -date -host -age ) )
}, $caller;
-f $file or return $self;
local $_ = do { local ( @ARGV, $/ ) = $file; <>; };
# strip out all xml comments
s{<!--.*?-->\s*}{}sg;
# get the header section
s{^(.+?)</query>}{}s or return;
my $header = $1;
for ($header) {
if (m{<host (?:\s+([^<>]*))? > \s*(.+?)\s* </host>}sx) {
my ( $attr, $content ) = ( $1, $2 );
$self->{-host} = $content;
}
if (m{<time (?:\s+([^<>]*))? > \s*(.+?)\s* </time>}sx) {
my ( $attr, $content ) = ( $1, $2 );
my %attr = main::parseXMLattrib($attr);
$self->{-age} = main::age( $time, $attr{epoch} ) if $attr{epoch};
$self->{-date} = $content;
}
}
# only retain the <resources> contents
s{^.*?<resources>}{}s and s{</resources>.*$}{}s or return;
## process <resource .../>
while (s{<resource (?:\s+([^/<>]*))? />}{}sx) {
my ($attr) = ($1);
my %attr = main::parseXMLattrib($attr);
my $name = delete $attr{name};
if ( defined $name ) {
for ( keys %attr ) {
$self->{-rc}{$name}{$_} = $attr{$_} || 0;
}
}
}
## process <resource ...> CONTENT </resource>
while (s{<resource (?:\s+([^<>]*))? > \s* (.*?) \s* </resource>}{}sx) {
my ( $attr, $content ) = ( $1, $2 );
my %attr = main::parseXMLattrib($attr);
my $name = delete $attr{name};
if ( defined $name ) {
for ( keys %attr ) {
$self->{-rc}{$name}{$_} = $attr{$_} || 0;
}
}
## process <user ...> COUNT </user>
while ( $content =~ s{<user (?:\s+([^<>]*))? >\s*(\d+)\s*</user>}{}sx )
{
my ( $attr, $count ) = ( $1, $2 );
my %attr = main::parseXMLattrib($attr);
my $user = delete $attr{name};
my $host = delete $attr{host};
if ( defined $user ) {
if ( defined $host ) {
$self->{-rc}{$name}{-where}{"$user\@$host"} = $count;
}
else {
## tag waiting with '[]'
$self->{-rc}{$name}{-where}{$user} = "[$count]";
}
}
}
}
return $self;
}
sub query {
my $self = shift;
%{ $self->{-rc} };
}
sub dump {
use Data::Dumper;
print Dumper( $_[0] );
}
sub available {
my $self = shift;
sort keys %{ $self->{-rc} };
}
# ------------------------------------------------------------------------
# processing of qlicserver.limits FILE or DIRECTORY
#
package qlicLimits;
sub new {
my $caller = shift;
my $diskValues = shift;
my $self = bless {}, $caller;
my $fileString;
if ( defined $diskValues and -f $diskValues ) {
$fileString = do {
local ( *FILE, $/ );
if ( open FILE, $diskValues ) {
<FILE>;
}
else {
undef;
}
};
}
elsif ( defined $diskValues and -d $diskValues ) {
local *DIR;
my $dir = $diskValues;
if ( opendir DIR, $dir ) {
my @files = grep { -f "$dir/$_" and -r _ } readdir DIR;
for my $name (@files) {
my $limit;
# use the last value
if ( open FILE, "$dir/$name" ) {
$limit = ( map { /^\s*(-?\d+)\s*$/ } <FILE> )[-1];
}
defined $limit or $limit = "NONE";
$self->{$name} = $limit;
}
}
}
for ($fileString) {
defined or next;
# strip out all comments
s{<!--.*?-->\s*}{}sg;
## process <resource .../> and <resource ...></resource>
while (s{<resource (?:\s+([^/<>]*))? />}{}sx
or s{<resource (?:\s+([^/<>]*))? >\s*</resource>}{}sx )
{
my %attr = main::parseXMLattrib($1);
my $name = delete $attr{name};
my $limit = delete $attr{limit};
if ( defined $name and defined $limit ) {
$self->{$name} = $limit;
}
}
}
return $self;
}
sub change {
my $caller = shift;
my $diskValues = shift;
my @args = @_;
@args or return;
my ( %pending, %adjusted );
for (@args) {
s{,}{ }g; # comma -> space-delimited
my %h = map { /^(.+?)=(.*)$/ } split;
for ( keys %h ) {
defined $h{$_} and length $h{$_} or $h{$_} = "NONE";
$pending{$_} = $h{$_};
}
}
keys %pending or return;
my $user = getpwuid $<;
if ( defined $diskValues and -d $diskValues ) {
local *DIR;
my $dir = $diskValues;
if ( opendir DIR, $dir ) {
my @files = grep { -f "$dir/$_" and -w _ } readdir DIR;
for my $name (@files) {
if ( exists $pending{$name} ) {
local *FILE;
if ( open FILE, ">", "$dir/$name" ) {
print FILE "# adjusted by $user $date\n",
"$pending{$name}\n";
$adjusted{$name} = delete $pending{$name};
}
}
}
}
}
for ( [ "adjusted" => \%adjusted ], [ "not adjusted" => \%pending ], ) {
my ( $label, $href ) = @$_;
keys %$href or next;
print "$label: ",
join( "," => map { qq{$_=$href->{$_}} } sort keys %$href ), "\n";
}
}
sub output {
my $self = shift;
my @list = map { qq{$_=$self->{$_}} } sort keys %$self;
print "limits: ";
if (@list) {
print join( "," => @list ), "\n";
}
else {
print "NONE\n";
}
}
# ------------------------------------------------------------------------
# main
#
package main;
import qlicCache;
# ------------------------------------------------------------------------
sub usage {
$! = 0; # clean exit
warn "@_\n" if @_;
die <<"USAGE";
usage:
$Script [OPTION]
$Script [OPTION] resource=limit .. resource=limit
with options:
-c FILE alternative location for the license cache
-C FILE alternative location for the license limit
-d dump cache file as raw xml
-D dump license cache in perl format
-f display free licenses only
-l list license limit
-q display free licenses via qhost query
-u license usage via 'lacct'
-U license usage per user via 'lacct -u'
-w show who/where ('[]' indicates waiting jobs)
-h this help
* extract / display information for the GridEngine license cache
$config->{-cache}
* adjust / display information for the license limits
$config->{-limits}
copyright (c) 2003-10 <Mark.Olesen\@faurecia.com>
Licensed and distributed under the Creative Commons
Attribution-NonCommercial-ShareAlike 3.0 License.
http://creativecommons.org/licenses/by-nc-sa/3.0
USAGE
}
# -------------------------------------------------------------------------
my %opt;
getopts( 'hc:C:DdflqUuw', \%opt ) or usage();
$opt{h} and usage();
if ( $opt{U} ) {
## user-based usage from accounting
my @query = ( "lacct", "-u" );
exec @query;
exit 2;
}
elsif ( $opt{u} ) {
## usage from accounting
my @query = ( "lacct", $opt{w} ? "-w" : () );
exec @query;
exit 2;
}
if ( $opt{d} ) {
my $file = $opt{c} || $config->{-cache};
if ( not -f $file and $file !~ m{/} ) {
$file = "$config->{-site}/$file";
}
-f $file or exit 1;
local $_ = do { local ( @ARGV, $/ ) = $file; <>; };
# do a basic check for well-formed xml
# this might not be the case if there is a race condition
# and the file has not been fully written
# check for '<?xml version="1.0"?><someTag ...' at the start
# and '</someTag>' at the end
my ($tag) = m{^<\?xml (?:\s+[^<>]*?)? \?>\s*\<(\w+)}sx;
unless ( $tag and m{</\Q$tag\E>\s*$} ) {
sleep 2; ## wait and try again
$_ = do { local ( @ARGV, $/ ) = $file; <>; };
}
$_ ||= ''; ## avoid uninitialized
print;
exit;
}
if ( $opt{q} ) {
my %free =
map { /^\s+gc:(\S+?)=(\d\S*)\s*$/ }
grep { /^global/ ... /^\S/ } qx{qhost -F};
$_ += 0 for values %free;
for ( sort keys %free ) {
my $intval = $free{$_} + 0; # normalize as integers
print "$_=$intval\n";
}
exit;
}
if ( $opt{l} ) {
qlicLimits->new( $opt{C} || $config->{-limits} )->output();
exit;
}
if (@ARGV) {
qlicLimits->change( $opt{C} || $config->{-limits}, @ARGV );
exit;
}
my $info = qlicCache->new( $opt{c} || $config->{-cache} );
$info->dump() if $opt{D};
my %resources = $info->query();
#
# display free licenses
#
if ( $opt{f} ) {
for my $resource ( sort keys %resources ) {
my $count = $resources{$resource} || {};
my $free = $count->{free} || 0;
print "$resource=$free\n" if $free;
}
exit;
}
#
# display who/where
#
if ( $opt{w} ) {
my ($len) = sort { $b <=> $a } map { length } keys %resources;
$len += 2;
my $fmt = "%-${len}s";
my $indent = sprintf "\n$fmt", '';
for my $resource ( sort keys %resources ) {
my $count = $resources{$resource} || {};
my @list = hashRefToString( $count->{-where} );
if (@list) {
printf $fmt, $resource;
print join( $indent => @list ), "\n";
}
}
exit;
}
#
# define table output format
#
my @outputList;
format =
# name total limit extern intern wait free
@<<<<<<<<<<< @>>>>> @>>>>> @>>>>> @>>>>> @>>>> @>>>>
@outputList
.
#
# display table header
# --------------------
{
my @info = qw( host age );
my ($len) = sort { $b <=> $a } map { length } @info;
print map {
my $k = sprintf "%-${len}s", $_;
my $v = $info->{"-$_"};
$v ? "$k = $v\n" : ();
} @info;
print "\n";
@outputList = qw( resource total limit extern intern wait free );
write;
s/./-/g for @outputList;
write;
}
#
# display table body
# ------------------
for my $resource ( sort keys %resources ) {
my $count = $resources{$resource} || {};
@outputList =
( $resource, @{$count}{qw( total limit extern intern waiting free )} );
my $type = $resources{$resource}{type} || 0;
# no total?
$_ ||= "?" for $outputList[1];
if ( $type eq "intern" ) {
$_ = "*" for $outputList[3];
}
elsif ( $type eq "track" ) {
$_ = "*" for $outputList[4];
}
# easy to read representation for zero
for (@outputList) {
defined $_ or $_ = '.';
}
write;
}
# ------------------------------------------------------------------------

2327
flex-grid/site/qlicserver Executable file

File diff suppressed because it is too large Load Diff

325
flex-grid/site/qloadsensor Executable file
View File

@ -0,0 +1,325 @@
#!/bin/bash
# $Id: qloadsensor 180 2010-09-17 15:46:41Z kasper $
#
# qloadsensor:
# load sensor for particular file systems and floating licenses
#
# NB:
# 1) add the new complexes (via qconf -mc) for the following:
# * complex configurations managed in the shell script
# eg, 'perl -x qloadsensor'
# * complex consumables managed global
# eg, 'qlicserver -c'
# 2) initialize the global complex consumables to be managed
# eg, 'qlicserver -C'
#
# copyright (c) 2003-10 <Mark.Olesen@faurecia.com>
#
# Licensed and distributed under the Creative Commons
# Attribution-NonCommercial-ShareAlike 3.0 License.
# http://creativecommons.org/licenses/by-nc-sa/3.0
# -----------------------------------------------------------------------------
#
# impose default GridEngine environment + ascertain the binary architecture
#
# you likely don't need to adjust these values, since the loadsensor is called
# from sge_execd, which in turn is started from /etc/init.d/n1ge and
# these variables should be correctly exported there
#
[ -d "$SGE_ROOT" ] || { echo "Error: SGE_ROOT=$SGE_ROOT not found"; exit 1; }
: ${SGE_CELL:=default}
: ${SGE_ARCH:=`$SGE_ROOT/util/arch`}
export SGE_ROOT SGE_CELL SGE_ARCH
# -----------------------------------------------------------------------------
# this script should run as the 'admin_user' registered in 'bootstrap'
#
if [ "$UID" -eq 0 ]
then
admin_user=$(sed -ne 's/^admin_user *//p' $SGE_ROOT/$SGE_CELL/common/bootstrap)
: ${admin_user:=root}
if [ $admin_user != root -a $(echo $admin_user | tr "A-Z" "a-z") != none ]
then
exec $SGE_ROOT/utilbin/$SGE_ARCH/adminrun $admin_user $0
fi
fi
# <settings>
# ========================================================================
# now that we are the admin_user, we can source our standard settings
# - customize *all* settings there (eg, license server settings)
# - ENSURE THAT '$SGE_site' IS DEFINED !!!
#
for i in $SGE_ROOT/$SGE_CELL/site/environ; do [ -f $i ] && . $i; done
# define (unique) cluster name if not already defined
if [ -z "$SGE_CLUSTER_NAME" -a -r "$SGE_ROOT/$SGE_CELL/common/cluster_name" ]
then
SGE_CLUSTER_NAME=$(cat $SGE_ROOT/$SGE_CELL/common/cluster_name 2>/dev/null)
fi
: ${SGE_CLUSTER_NAME:=default}
export SGE_CLUSTER_NAME
SGE_site="$SGE_ROOT/flex-grid/site"
#
# ========================================================================
# </settings>
###############################################################################
###############################################################################
# CUSTOMIZE THESE SETTINGS - iff. required
qlicserver="$SGE_site/qlicserver config=$SGE_site/../config/local_licenses.conf dir=$SGE_ROOT/flex-grid/cache output=$SGE_ROOT/flex-grid/cache/qlicserver.xml qhost=qhost.xml qstat=qstat.xml"
diskmon="$SGE_site/diskmon.pl"
# END OF CUSTOMIZE SETTINGS
###############################################################################
###############################################################################
#
# the real (not compiled in) architecture
#
os_arch=`$SGE_ROOT/util/arch`
SGE_utilbin=$SGE_ROOT/utilbin/$os_arch
#
# set some constants
#
HOST=$($SGE_utilbin/gethostname -aname)
UQHOST=$(echo $HOST | cut -f1 -d.)
SGE_qmaster=unknown; export SGE_qmaster
# -----------------------------------------------------------------------------
# act_qmaster
#
# extract the unqualified host name from the "act_qmaster" file
# return this value or 'unknown' on failure
#
act_qmaster()
{
tmp=$(cat $SGE_common/act_qmaster 2>/dev/null)
echo ${tmp:-unknown}
}
# -----------------------------------------------------------------------------
# df_info
#
# echo the $1_{total,used,free} space on filesystem $2
#
# gridengine uses the suffixes
# 'k' => blocksize 1000
# 'K' => blocksize 1024
#
# return 0 if 'df' fails
df_info()
{
# 1:tag 2:mount 3:filesys 4:total 5:Used 6:Avail 7:Used% 8:Mount
[ -d "$2" ] && set -- $1 $2 $( df -k -P $2 2>/dev/null | tail -1 )
#!# we could add the following check:
#!# [ "$2" != "$8" ] && set -- $1 $2; # mount point mismatch?
[ "$#" -ge 6 ] || set -- $1 $2 filesystem 0 0 0
echo "$UQHOST:$1_total:$4K"
echo "$UQHOST:$1_used:$5K"
#if [ -w "$2" ]
#then
echo "$UQHOST:$1_free:$6K"
#else
# echo "$UQHOST:$1_free:0"
#fi
}
# invariant values
if [ -e "/proc/cpuinfo" ]
then
# mips=$(awk '{if (/mips/) printf "%.0f\n", $NF}' /proc/cpuinfo | tail -1)
mips=$(awk 'BEGIN {mips=0} /mips/ {if ($NF > mips) mips=$NF }; END {print mips}' /proc/cpuinfo)
else
mips=0
fi
unset os_name
# extract lsb_release
if [ -e "/usr/bin/lsb_release" ]
then
os_name=$(/usr/bin/lsb_release -ircs | xargs echo | sed 's/ /_/g')
else
os_name='unkown'
fi
: ${os_name:=NONE}
# -----------------------------------------------------------------------------
# host_info
#
# report host specific information about filesystems, logins,
# special hardware extensions, etc.
#
host_info()
{
echo "$UQHOST:arch:$os_arch"
echo "$UQHOST:os:$os_name"
# df_info tmp /tmp
df_info scratch /scratch
echo "$UQHOST:mips:$mips"
}
# -----------------------------------------------------------------------------
# iidle_info()
# report a machine's idle time
#
# parse the contents from /proc/interrupts, which looks like the following:
#
# CPU0
# 0: 23024789 XT-PIC timer
# 1: 13 XT-PIC keyboard
# 2: 0 XT-PIC cascade
# 5: 0 XT-PIC usb-uhci
# 8: 2 XT-PIC rtc
# 9: 0 XT-PIC acpi
# 10: 0 XT-PIC ehci-hcd, usb-uhci
# 11: 16687253 XT-PIC eth0, usb-uhci, Intel 82801DB-ICH4, nvidia
# 12: 20 XT-PIC PS/2 Mouse
# 14: 77178 XT-PIC ide0
# 15: 2 XT-PIC ide1
# NMI: 0
# LOC: 0
# ERR: 0
# MIS: 0
#
# or,
#
# CPU0 CPU1
# 0: 12820049 12818168 IO-APIC-edge timer
# 1: 42889 43309 IO-APIC-edge keyboard
# 2: 0 0 XT-PIC cascade
# 8: 2 0 IO-APIC-edge rtc
# 9: 0 0 IO-APIC-edge acpi
# 12: 287235 296531 IO-APIC-edge PS/2 Mouse
# 14: 47423 40923 IO-APIC-edge ide0
# 15: 2 3 IO-APIC-edge ide1
# 16: 7733868 7737081 IO-APIC-level nvidia
# 17: 159 156 IO-APIC-level Intel ICH 82801AA
# 19: 2155710 2159943 IO-APIC-level e100, usb-uhci
# NMI: 0 0
# LOC: 25641034 25641033
# ERR: 0
# MIS: 0
#
# Thus, we need the [-1, 1..$ncpu] fields for the following sources:
# keyboard, Mouse, serial
#
# NB: adding 'usb-uhci' gives problems, since this is sometimes
# attached to the ethernet card
#
# set the variable 'iidle' to the idle time (seconds) since the last call
#
last="0 -1";
iidle_info()
{
set -- $(
perl -e '
my @last = @ARGV;
@ARGV = "/proc/interrupts";
$_ = <>;
my $ncpu = s/\s*CPU\d+//g || 0;
my ( $iidle, $int, $now ) = ( 0, 0, time );
$int += $_
for
map { /\s+(keyboard|Mouse|serial)$/ ? (split)[ 1 .. $ncpu ] : (); }
<>;
if ( $int == $last[-1] ) { # no interactivity since last round
$iidle = ( $now - $last[0] );
}
else {
@last = ( $now, $int );
}
print "$iidle @last\n";
' $last
);
echo "$UQHOST:iidle:$1";
shift; last="$@"; # save for later
}
# -----------------------------------------------------------------------------
#
# The execd running on the qmaster queries the license server
# The contents of 'act_qmaster' should suffice to migrate the load sensor
# for a controlled migration.
#
while :
do
read input || exit 1 # wait for input
[ "$input" = quit ] && exit 0
echo begin # begin load report
host_info # host information
iidle_info # machine's idle time
echo end # end load report
# let the license query run between load reports
# SGE_qmaster=`act_qmaster` # refresh the name of the qmaster
# if [ "$HOST" = "$SGE_qmaster" ]
if [ "$HOST" = "minos19" ]
then
# $qlicserver 2>> qloadsensor.err
$SGE_ROOT/flex-grid/site/qlicserver config=$SGE_ROOT/flex-grid/config/local_licenses.conf output=$SGE_ROOT/flex-grid/cache/qlicserver_local.xml
$SGE_ROOT/flex-grid/site/qlicserver config=$SGE_ROOT/flex-grid/config/abaqus_licenses.conf timeout=60 output=$SGE_ROOT/flex-grid/cache/qlicserver_abaqus.xml
# $SGE_ROOT/flex-grid/site/qlicserver config=/opt/SGE/flex-grid/config/trelis_licenses.conf timeout=60 output=$SGE_ROOT/flex-grid/cache/qlicserver_trelis.xml
$SGE_ROOT/flex-grid/site/qlicserver config=/opt/SGE/flex-grid/config/comsol_licenses.conf timeout=60 output=$SGE_ROOT/flex-grid/cache/qlicserver_comsol.xml
$SGE_ROOT/flex-grid/site/qlicserver config=$SGE_ROOT/flex-grid/config/matlab_licenses.conf timeout=60 output=$SGE_ROOT/flex-grid/cache/qlicserver_matlab.xml
lockfile $SGE_ROOT/flex-grid/cache/qlicserver.xml.lock
# (sed '/<\/resources>/,$ d' $SGE_ROOT/flex-grid/cache/qlicserver_abaqus.xml ; sed '1,/<resources>/d' $SGE_ROOT/flex-grid/cache/qlicserver_trelis.xml | grep -v qlicserver | grep -v resources ; sed '1,/<resources>/d' $SGE_ROOT/flex-grid/cache/qlicserver_local.xml | grep -v qlicserver | grep -v resources ; sed '1,/<resources>/d' $SGE_ROOT/flex-grid/cache/qlicserver_matlab.xml;) > $SGE_ROOT/flex-grid/cache/qlicserver.xml
# (sed '/<\/resources>/,$ d' $SGE_ROOT/flex-grid/cache/qlicserver_abaqus.xml ; sed '1,/<resources>/d' $SGE_ROOT/flex-grid/cache/qlicserver_local.xml | grep -v qlicserver | grep -v resources ; sed '1,/<resources>/d' $SGE_ROOT/flex-grid/cache/qlicserver_matlab.xml;) > $SGE_ROOT/flex-grid/cache/qlicserver.xml
(sed '/<\/resources>/,$ d' $SGE_ROOT/flex-grid/cache/qlicserver_abaqus.xml ; sed '1,/<resources>/d' $SGE_ROOT/flex-grid/cache/qlicserver_local.xml | grep -v qlicserver | grep -v resources; sed '1,/<resources>/d' $SGE_ROOT/flex-grid/cache/qlicserver_comsol.xml | grep -v qlicserver | grep -v resources ; sed '1,/<resources>/d' $SGE_ROOT/flex-grid/cache/qlicserver_matlab.xml;) > $SGE_ROOT/flex-grid/cache/qlicserver.xml
rm -f $SGE_ROOT/flex-grid/cache/qlicserver.xml.lock
# $diskmon -m 2>> qloadsensor.err
# force rescheduling of express jobs
# $SGE_site/qxprs >/dev/null 2>&1
# else
# $diskmon 2>> qloadsensor.err
fi
done
exit 0 # we never get here, but just in case
#------------------------------------------------------------------------------
# feed via 'perl -x' to extract the 'host' complex configuration
#!/usr/bin/perl -w
print <DATA>
__DATA__
#
# host complex configuration
#
#name shortcut type relop requestable consumable default urgency
#---------------------------------------------------------------------------
tmp_total tmpt MEMORY <= YES NO 0 0
tmp_used tmpu MEMORY >= NO NO 0 0
tmp_free tmpf MEMORY <= YES NO 0 0
iidle iidle INT <= YES NO 0 0
mips mips INT <= YES NO 0 0
os os RESTRING == YES NO NONE 0
abaqus abaqus DOUBLE <= YES YES 0 0
cae cae DOUBLE <= YES YES 0 0
comsol comsol DOUBLE <= YES YES 0 0
hyper hyper DOUBLE <= YES YES 0 0
ifort ifort DOUBLE <= YES YES 0 0
matlab matlab DOUBLE <= YES YES 0 0
mcc mcc DOUBLE <= YES YES 0 0
multiphysics multiphysics DOUBLE <= YES YES 0 0
trelis trelis DOUBLE <= YES YES 0 0
scratch_free scratch_free MEMORY <= YES YES 0 0
scratch_total scratch_total MEMORY <= YES NO 0 0
scratch_used scratch_used MEMORY >= NO NO 0 0
# -----------------------------------------------------------------------------

View File

@ -1,5 +1,5 @@
#!/usr/bin/ksh
# $Id: suspend.sh 365 2013-11-18 09:58:17Z kasper $
# This script should be added as the SUSPEND_METHOD in the
# queue definition with a $job_pid, $job_id, and $job_owner arguments.
# e.g. script.sh $job_pid $job_id $job_owner

30
local/bin/term.sh Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/ksh
# This script should be added as the TERMINATE_METHOD in the
# queue definition with $job_pid, $job_id, $job_owner, and interval arguments.
# e.g. script.sh $job_pid $job_id $job_owner 90
if [ -z "$4" ]
then
echo "Usage: $0 \$job_pid \$job_id \$job_owner interval"
exit 1
fi
#echo "Term script Running on $(hostname): $USER $1 $2 $3 $4" >> ~$3/qdel_log.log
#echo $(pgrep -g $1) >> ~$3/qdel_log.log
for sig in INT TERM KILL
do
stat=$(pgrep -g $1 -u $3)
if [ ! -z "${stat}" ]
then
#echo "Sending SIG${sig} to $1" >> ~$3/qdel_log.log
/usr/bin/pkill --signal ${sig} -g $1
sleep $4
else
break
fi
done
#uncomment the following for debugging
#echo "Job $2 killed." >> ~$3/qdel_log.log

View File

@ -0,0 +1,81 @@
#!/bin/bash
#############################################################
# This example produces a very simple plot and #
# saves it as Matlab figure file and as PNG file #
#############################################################
#############################################################
# set qsub options #
#############################################################
# run in low.q
#$ -l low
# request enough memory
#$ -l h_vmem=8G,memory=8G,h_stack=8M
# request 1 matlab license.
#$ -l matlab=1
# Name the job 'Matlab'
#$ -N Matlab
# send e-mail after job has finished
# use the -M option to define your e-mail address
# #$ -M meine-email@example.org
#$ -m e
# join stdout and stderr in one file
#$ -j y
#############################################################
# output hostname and date (comment out if not needed) #
#############################################################
echo "Runnning Matlab on host " `hostname`
echo "Starting Matlab at " `date`
#############################################################
# launch matlab #
#############################################################
# run non-interactive Matlab session
# use no display (-nodisplay)
# don't show splash screen at startup (-nosplash)
# don't start the matlab desktop (-nodesktop)
# use software opengl (-softwareopengl)
# only use single threaded computations (limit to use of 1 core, -singleCompThread)
# execute all matlab commands between '<< END' and matching 'END'
# Don't forget to add 'exit' and 'END' after replacing
# the commands with your own!
/opt/matlab/bin/matlab -nodisplay -nosplash -nodesktop -softwareopengl -singleCompThread << END
% get environment variable JOB_ID
jobid=str2num(getenv('JOB_ID'));
if isempty(jobid)
jobid = 0;
end
% create filenames for the figure
filename=sprintf('matlab_figure_%d', jobid);
% create new empty figure and save figure handle
fh = figure();
% draw plot
plot(-pi:0.01:pi, sin(-pi:0.01:pi));
% save figure as matlab figure and PNG
saveas(fh, filename, 'fig');
saveas(fh, filename, 'png');
% EXIT MATLAB
exit;
END
#############################################################
# output date (comment out if not needed) #
#############################################################
echo "Matlab finnished at " `date`

View File

@ -0,0 +1,23 @@
#!/bin/bash
# This is a simple example of a SGE batch script
#$ -pe mpi-rr 4-20
#$ -l low
# request Bourne shell as shell for job
#$ -S /bin/bash
#
# print hostname
hostname
# print date and time
date
if [ "X$PE_HOSTFILE" != "X" ]; then
# print pe_hostfile
cat $PE_HOSTFILE
# Run ompi_connectivity
echo Starting OpenMPI job.
mpirun -v /data/gridengine/local/examples/jobsbin/ompi_connectivity_`/usr/bin/lsb_release -cs`
fi
# print date and time again
date

View File

@ -0,0 +1,23 @@
#!/bin/bash
# This is a simple example of a SGE batch script
#$ -pe mpi-rr 4-20
#$ -l low
# request Bourne shell as shell for job
#$ -S /bin/bash
#
# print hostname
hostname
# print date and time
date
if [ "X$PE_HOSTFILE" != "X" ]; then
# print pe_hostfile
cat $PE_HOSTFILE
# Run ompi_hello
echo Starting OpenMPI job.
mpirun -v /data/gridengine/local/examples/jobsbin/ompi_hello_$(/usr/bin/lsb_release -cs)
fi
# print date and time again
date

View File

@ -0,0 +1,23 @@
#!/bin/bash
# This is a simple example of a SGE batch script
#$ -pe mpi-rr 4-20
#$ -l low
# request Bourne shell as shell for job
#$ -S /bin/bash
#
# print hostname
hostname
# print date and time
date
if [ "X$PE_HOSTFILE" != "X" ]; then
# print pe_hostfile
cat $PE_HOSTFILE
# Run ompi_ring
echo Starting OpenMPI job.
mpirun -v /data/gridengine/local/examples/jobsbin/ompi_ring_`/usr/bin/lsb_release -cs`
fi
# print date and time again
date

View File

@ -0,0 +1,75 @@
#!/bin/bash
# This job script takes a nap for 10 seconds (or paramter $2) every 30 minutes (or paramter $1)
# SGE options
#$ -N PSleeper
#$ -l scf=1M,mem=100M,h_vmem=100M
#$ -q normal.q
#$ -cwd
# process args
case "$1" in
-h)
echo "usage: $0 [-h | [-d] [T] [nap]]"
echo "periodically take a nap"
echo ""
echo "-h print this help and exit"
echo "-d print debug info"
echo "T take a nap every T minutes (default: 30)"
echo "nap take a nap for nap seconds (default: 10)"
exit 1
;;
*)
debug=0
terse="-terse"
debug_flag=""
do_echo=0
T=30
nap=10
while (( "$#" )); do
case "$1" in
-d)
debug=1
terse=""
debug_flag="-d"
do_echo=1
;;
*)
T=${1:-30}
nap=${2:-10}
break
;;
esac
shift
done
;;
esac
# set other variables
next=$(date -d "${T} minutes" +%Y%m%d%H%M)
script=$0
# output some informations
if [ ${debug} -eq 1 ]; then
echo "T = ${T}, nap=${nap}"
echo "next run at ${next} (YYYYMMDDhhmm)"
echo "debug_flag = ${debug_flag}, do_echo = ${do_echo}"
echo ""
fi
# commands to run in Grid Engine
${script} ${nap} ${do_echo}
# re-submit script to execute in T minutes
jobid=$(qsub ${terse} -a ${next} ${script} ${debug_flag} ${T} ${nap})
exit_code=$?
if [ ${debug} -eq 1 ]; then
echo "${jobid}"
fi
if [ ${exit_code} -ne 0 ]; then
if [ ${debug} -eq 1 ]; then
echo "${jobid}"
echo "Ups, something went wrong, check output!"
fi
exit ${exit_code}
fi

View File

@ -0,0 +1,45 @@
#! /bin/bash
#############################################################
# This example show a list of availabel conda environments #
#############################################################
#############################################################
# set qsub options #
#############################################################
# run in low.q
#$ -l low
# request enough memory
# #$ -l h_vmem=8G,memory=8G,h_stack=8M
# Name the job 'Conda-Test'
#$ -N Conda-Test
# send e-mail after job has finished
# use the -M option to define your e-mail address
# #$ -M my-email@example.org
#$ -m e
# join stdout and stderr in one file
#$ -j y
#############################################################
# initialize conda #
#############################################################
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/opt/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
#############################################################
# show conda environments #
#############################################################
conda env list

View File

@ -0,0 +1,77 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2006-2007 Sun Microsystems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Use the Open MPI-provided wrapper compilers. Note that gmake
# requires the CXX macro, while other versions of make (such as Sun's
# make) require the CCC macro.
CC = mpicc
CXX = mpic++
CCC = mpic++
F77 = mpif77
FC = mpif90
# Using -g is not necessary, but it is helpful for example programs,
# especially if users want to examine them with debuggers. Note that
# gmake requires the CXXFLAGS macro, while other versions of make
# (such as Sun's make) require the CCFLAGS macro.
CFLAGS = -g
CXXFLAGS = -g
CCFLAGS = -g
F77FLAGS = -g
FCFLAGS = -g
# Example programs to build
EXAMPLES = hello_c hello_cxx hello_f77 hello_f90 \
ring_c ring_cxx ring_f77 ring_f90 connectivity_c
# Default target. Always build the C example. Only build the others
# if Open MPI was build with the relevant language bindings.
all: hello_c ring_c connectivity_c
@ if test "`ompi_info --parsable | grep bindings:cxx:yes`" != ""; then \
$(MAKE) hello_cxx ring_cxx; \
fi
@ if test "`ompi_info --parsable | grep bindings:f77:yes`" != ""; then \
$(MAKE) hello_f77 ring_f77; \
fi
@ if test "`ompi_info --parsable | grep bindings:f90:yes`" != ""; then \
$(MAKE) hello_f90 ring_f90; \
fi
# The usual "clean" target
clean:
rm -f $(EXAMPLES) *~ *.o
# Don't rely on default rules for the fortran examples
hello_f77: hello_f77.f
$(F77) $(F77FLAGS) $^ -o $@
ring_f77: ring_f77.f
$(F77) $(F77FLAGS) $^ -o $@
hello_f90: hello_f90.f90
$(FC) $(FCFLAGS) $^ -o $@
ring_f90: ring_f90.f90
$(FC) $(FCFLAGS) $^ -o $@

View File

@ -0,0 +1,42 @@
# -*- makefile -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Note that this file does not stand on its own. It is included by a
# higher-level Makefile so that Automake features such as "make dist"
# work properly (and include all the relevant files in this directory
# in the distribution tarball).
# If you are looking for the file that builds these examples, look at
# "Makefile" in this same directory (it is *NOT* generated by
# Automake).
EXTRA_DIST += \
examples/README \
examples/Makefile \
examples/hello_c.c \
examples/hello_cxx.cc \
examples/hello_f77.f \
examples/hello_f90.f90 \
examples/ring_c.c \
examples/ring_cxx.cc \
examples/ring_f77.f \
examples/ring_f90.f90 \
examples/connectivity_c.c

View File

@ -0,0 +1,46 @@
Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
University Research and Technology
Corporation. All rights reserved.
Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
The files in this directory are sample MPI applications provided both
as a trivial primer to MPI as well as simple tests to ensure that your
Open MPI installation is working properly.
If you are looking for a comprehensive MPI tutorial, these samples are
not enough. An excellent MPI tutorial is available here:
http://webct.ncsa.uiuc.edu:8900/public/MPI/
There are 2 MPI examples in this directory, each in four languages:
- Hello world
C: hello_c.c
C++: hello_cxx.cc
F77: hello_f77.f
F90: hello_f90.f90
- Send a trivial message around in a ring
C: ring_c.c
C++: ring_cxx.cc
F77: ring_f77.f
F90: ring_f90.f90
- Test the connectivity between all processes
C: connectivity_c.c
The Makefile in this directory will build as many of the examples as
you have language support (e.g., if you do not have F90 bindings
compiled as part of Open MPI, the F90 examples will be skipped).
The Makefile assumes that the wrapper compilers mpicc, mpic++, mpif77,
and mpif90 are in your path.
Although the Makefile is tailored for Open MPI (e.g., it checks the
"ompi_info" command to see if you have support for C++, F77, and F90),
all of the example programs are pure MPI, and therefore not specific
to Open MPI. Hence, you can use a different MPI implementation to
complie and run these programs if you wish.
Make today an Open MPI day!

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
*/
/*
* Test the connectivity between all processes.
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
#include <unistd.h>
#include <mpi.h>
int
main(int argc, char **argv)
{
MPI_Status status;
int verbose = 0;
int rank;
int np; /* number of processes in job */
int peer;
int i;
int j;
int length;
char name[MPI_MAX_PROCESSOR_NAME+1];
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &np);
/*
* If we cannot get the name for whatever reason, just
* set it to unknown. */
if (MPI_SUCCESS != MPI_Get_processor_name(name, &length)) {
strcpy(name, "unknown");
}
if (argc>1 && strcmp(argv[1], "-v")==0)
verbose = 1;
for (i=0; i<np; i++) {
if (rank==i) {
/* rank i sends to and receives from each higher rank */
for(j=i+1; j<np; j++) {
if (verbose)
printf("checking connection between rank %d on %s and rank %-4d\n",
i, name, j);
MPI_Send(&rank, 1, MPI_INT, j, rank, MPI_COMM_WORLD);
MPI_Recv(&peer, 1, MPI_INT, j, j, MPI_COMM_WORLD, &status);
}
} else if (rank>i) {
/* receive from and reply to rank i */
MPI_Recv(&peer, 1, MPI_INT, i, i, MPI_COMM_WORLD, &status);
MPI_Send(&rank, 1, MPI_INT, i, rank, MPI_COMM_WORLD);
}
}
MPI_Barrier(MPI_COMM_WORLD);
if (rank==0)
printf("Connectivity test on %d processes PASSED.\n", np);
MPI_Finalize();
return 0;
}

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
*
* Sample MPI "hello world" application in C
*/
#include <stdio.h>
#include "mpi.h"
int main(int argc, char* argv[])
{
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("Hello, world, I am %d of %d\n", rank, size);
MPI_Barrier(MPI_COMM_WORLD);
MPI_Finalize();
return 0;
}

View File

@ -0,0 +1,24 @@
//
// Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
// University Research and Technology
// Corporation. All rights reserved.
// Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
//
// Sample MPI "hello world" application in C++
//
#include "mpi.h"
#include <iostream>
int main(int argc, char **argv)
{
int rank, size;
MPI::Init();
rank = MPI::COMM_WORLD.Get_rank();
size = MPI::COMM_WORLD.Get_size();
std::cout << "Hello, world! I am " << rank << " of " << size << std::endl;
MPI::Finalize();
return 0;
}

Binary file not shown.

View File

@ -0,0 +1,20 @@
C
C Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
C University Research and Technology
C Corporation. All rights reserved.
C Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
C
C Sample MPI "hello world" application in Fortran 77
C
program main
implicit none
include 'mpif.h'
integer ierr, rank, size
call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierr)
print *, "Hello, world, I am ", rank, " of ", size
call MPI_FINALIZE(ierr)
end

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More