One often wants to execute some setup work before running an application.
A typical example is setting the environment by way of the module
command before running an MPI application.
The straightforward, but not elegant, way of doing that is to create a script, say mpijob.sh, which contains
module load mpi
mpirun -np 16 my_mpi_app
This has several disadvantages: (1) it requires to submit a script (myjob.sh) to the execution site id addition to the job description; (2) it requires hard-coding in the script the number of processes; (3) it forces the user to specfiy low-level and site-dependent information such as the MPI-launcher program, e.g., mpirun or mpiexec.
A better way is to include the setup work as part of the job description submitted to Globus, and to leave the MPI-launching mechanism to be handled by the execution site. That is, we would like something like
<job>
<executable>my_mpi_app</executable>
<directory>${GLOBUS_USER_HOME}</directory>
...
<count>16</count>
...
<jobType>mpi</jobType>
<extensions>
<preamble>
module load mpi
</preamble>
</extensions>
</job>
To implement the solution, one has to insert in the LRMS adapter code that:
Next we show what changes need to be made to the SGE and PBS adapters.
$sge_job_script->print("# Change to directory requested by user\n");
$sge_job_script->print('cd ' . $description->directory() . "\n");
these lines
#
# Insert the application preamble
#
if( $description->preamble() ) {
$self->log("INFO: Preamble:\n");
$self->log( $description->preamble() );
$sge_job_script->print("\n# Preamble\n");
$sge_job_script->print( $description->preamble() . "\n\n");
}
$rsh_env = '';
$library_vars{LD_LIBRARY_PATH} = 0;
these lines
#
# Insert the application preamble
#
if( $description->preamble() ) {
$self->log("INFO: Preamble:\n");
$self->log( $description->preamble() );
print JOB "\n# Preamble\n";
print JOB $description->preamble() . "\n\n";
}
The idea can be used to implement a postamble, where one puts commands to be executed after the application runs, e.g., file cleanup or file copying.
If you have questions, contact Gabriel Mateescu, mateescu@acm.org