Simple pointers on using perl scripts and grid engine on MSI machines

From NeuralNetoff

Jump to: navigation, search

The individual MSI machines may not be as fast as the Dell Core 2 machines, but the PBS grid engine on the MSI machines offer the ability to easily run up to 20 processes in parallel, which can be quite helpful when you are exploring a parameter space. My lab experience has been with Matlab, so that is what I am going to concentrate upon.

Minnesota Supercomputing Institute (MSI)

If you haven't gotten a MSI account, ask Tay to apply for one for you. Here is their webpage. There are several computer labs in MSI. Nearly all of our work as been done on the Scientific Development & Visualization Lab (SDVL) linux machines, but we have also used BSCL & another one that escapes me. Those were chosen because they had the software we wanted. The other labs were explored in search of more computer time, but, when I last checked, the SDVL machines appeared to be the ones most lightly used by others. Login into a relevant machine (e.g. l5.msi.umn.edu). Computers l3, l4, l5 and l6 are set up the run batch jobs, and the rest of the "l#"'s are used for folks physically in the lab. If you try to log in and it says you have the wrong password or account, the most likely reason is that they changed the batch job machines. So, try to log onto another machine with the same login and password.

Intro to Submitting Jobs to Grid Engine

Jobs need to be submitted through the PBS grid engine if you don't want them deleted. The grid engine divides computer time equitably to all the folks who are submitting jobs to the lab's engine. Use qsub to submit jobs (see perl example below for more details), qstat to see what jobs are running, yours and others, on the grid engine system and their ID numbers, and qdel <ID number> to delete the job with <<ID Number>>. For more information submitting batch jobs on the grid engine, look at MSI's grid engine page.

If you want to use the parallel capability of grid engine, you need to submit multiple jobs, and this can be done quickly using a perl script...

Quick & Dirty Intro to Perl Scripts

Because I have used perl scripts almost exclusively for parameter space explorations in Matlab, that is what I will concentrate on explaining. Perl is a programming language that allows the easy manipulation of scripts, and much of its appeal is from its easy handling of strings. "Scalar" variables, such as strings, in perl are preceded by a "$", (e.g. $rho, below). Comments are preceded by "#." Here is a short perl program that runs a Matlab program "IzMLNetEfull5constantI.m" over a 2-D range of parameter space, using a variety of different I's and gEPSP's and saving the results to numbered output files.


#! /usr/local/bin/perl
# This perl script runs a range of excitatory gEPSPs and DC currents
# Below are parameters for the gEPSP search
$gEPSPstart=0.025;#0.1; #0.3;
$NumgEPSP=10;
$gEPSPGrRate=0.1444; 
# parameters for the current I search
$NumI=10;
$Iincr=7;
$startingI = 45;
# Other parameters that don't change in these sims
$rho = 0.01;
$T=300;
# Within these loops, a
for ($k = 0; $k < $startingK+$NumgEPSP; $k++)
{
   for ($j = 0; $j < $NumI; $j++)
   {
 # constructing the suffix that tells which simulation this is
       $nameVal = ($k < 10)?"0".$k:$k;
       $nameVal .= ($j < 10)?"0".$j:$j;
 # creating the script files NetRunIEsyn2Full$nameVal.m
       system("touch NetRunIEsyn2Full$nameVal.m");
 # I is scaled linearly
       $I=$startingI + $j*$Iincr;
 # gEPSP is scaled logarithmically
       $gEPSP = $gEPSPstart*(10**($gEPSPGrRate*$k));
 # writing the matlab script to run
       system("echo addpath ~/EINet > NetRunIEsyn2Full$nameVal.m");
       system("echo cd ~/EINet >> NetRunIEsyn2Full$nameVal.m");
 # IzMLNetEfull5constantI.m is the name of the actual Matlab program to which a number of parameter are
 # given...
       system("echo SpikeTimes = IzMLNetEfull5constantI\\($T, \\'gepsp\\', $gEPSP, \\'i\\', $I\\)\\; >>  NetRunIEsyn2Full$nameVal.m");
 # what to save where
       system("echo save NetOutIEsyn2Full$nameVal SpikeTimes >> NetRunIEsyn2Full$nameVal.m");
 #Start the data running
       system("qsub -v Mfile=NetRunIEsyn2Full$nameVal Njob.sh");
   }
}
system("echo finished");

You can learn more about perl by checking out pages such as [this]. What is "Njob.sh", you ask? Good question. It is a shell script that has the proper options for doing a batch job with Matlab and the PBS grid-engine. See for your self...

#!/bin/bash
#PBS -q linux64
#PBS -l nodes=1,mem=1gb,walltime=23:00:00
#PBS -m abe
echo 'Starting Matlab...'
echo 'Running File '$Mfile
/usr/local/matlab/matlab-R2007a/bin/matlab -nosplash -nojvm -r $Mfile


NOTE: More MSI computer resources are open to you if you use code with explicit parallel processing such as MPI. Although I attended an afternoon MPI intro, I did not invest enough time to pursue it.

--Warrencp 14:32, 10 March 2009 (CDT)

Personal tools