Am 17.05.2011 um 16:20 schrieb Chris Jewell:

> Does anybody have a (simple) way of obtaining the requested number of slots 
> for, say, a parallel SMP interactive session from within that session?  I'm 
> currently having an issue with Matlab spawning too many threads and causing 
> load average problems: Matlab by default uses as many threads as there are 
> CPUs on a physical machine, but I use core binding to control such unwise 
> assumptions.  Therefore, for optimum performance, it would be really useful 
> to write a script in the matlabrc file that grabs the number of requested SMP 
> slots, and sets the maxNumCompThreads accordingly.

You can add this to your ~/.profile or alike:

MYPARENT=`ps -p $$ -o ppid --no-header`
#MYPARENT=`ps -p $MYPARENT -o ppid --no-header`
#MYPARENT=`ps -p $MYPARENT -o ppid --no-header`
MYSTARTUP=`ps -p $MYPARENT -o command --no-header`
if [ "${MYSTARTUP:0:13}" = "sge_shepherd-" ]; then
   echo "Running inside SGE" 
   MYJOBID=${MYSTARTUP:13}
   MYJOBID=${MYJOBID% -bg}
   echo "Job $MYJOBID"
   . /var/spool/sge/$HOSTNAME/active_jobs/$MYJOBID.1/environment
   unset HISTFILE
fi

(adjust the path to the spool directory).

Then you can also export:

export OMP_NUM_THREADS=$NSLOTS

or any other environment variable which is necessary.

==

How many lines of:

MYPARENT=`ps -p $MYPARENT -o ppid --no-header`

you need depends on the startup method you used (whether it's -builtin-, rsh or 
ssh).

==

reuti@pc15370:~> qrsh -l h=pc15370
Running inside SGE
Job 459
reuti@pc15370:~> echo $NSLOTS
1

-- Reuti
_______________________________________________
users mailing list
[email protected]
https://gridengine.org/mailman/listinfo/users

Reply via email to