Changeset 215


Ignore:
Timestamp:
03/28/10 19:24:19 (6 years ago)
Author:
mmckerns
Message:

initial add of launchers for srun and moab

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyina/pyina/launchers.py

    r213 r215  
    1818 
    1919     
    20 def tasks(nodes): 
    21     """ compute # of tasks from node string of pattern = N[:TYPE][:ppn=P] 
    22     For example, tasks("3:core4:ppn=2") yields 6 """ 
     20def mpirun_tasks(nodes): 
     21    """ 
     22compute mpirun task_string from node string of pattern = N[:TYPE][:ppn=P] 
     23For example, mpirun_tasks("3:core4:ppn=2") yields 6 
     24    """ 
    2325    nodestr = str(nodes) 
     26    nodestr = nodestr.split(",")[0]  # remove appended -l expressions 
    2427    nodelst = nodestr.split(":") 
    2528    n = int(nodelst[0]) 
     
    3336 
    3437 
     38def srun_tasks(nodes): 
     39    """ 
     40compute srun task_string from node string of pattern = N[:ppn=P][,partition=X] 
     41For example, srun_tasks("3:ppn=2,partition=foo") yields '3 -N2' 
     42    """ 
     43    nodestr = str(nodes) 
     44    nodestr = nodestr.split(",")[0]  # remove appended -l expressions 
     45    nodelst = nodestr.split(":") 
     46    n = int(nodelst[0]) 
     47    nodelst = nodestr.split("ppn=") 
     48    if len(nodelst) > 1: 
     49        ppn = nodelst[1] 
     50        ppn = int(ppn.split(":")[0]) 
     51        tasks = "%s -N%s" % (n, ppn) 
     52    else: 
     53        tasks = "%s" % n 
     54    return tasks 
     55 
     56 
    3557def serial_launcher(kdict={}): 
    3658    """ 
     
    3860syntax:  (python) (file) (progargs) 
    3961 
    40 NOTE: run non-python commands with: {'python':'', ...}  
     62NOTES: 
     63 - run non-python commands with: {'python':'', ...}  
    4164    """ 
    4265    mydict = defaults.copy() 
     
    5174syntax:  mpirun -np (nodes) (python) (file) (progargs) 
    5275 
    53 NOTE: run non-python commands with: {'python':'', ...}  
     76NOTES: 
     77 - run non-python commands with: {'python':'', ...}  
    5478    """ 
    5579    mydict = defaults.copy() 
    5680    mydict.update(kdict) 
    5781    str =  """ mpirun -np %(nodes)s %(python)s %(file)s %(progargs)s""" % mydict 
     82    return str 
     83 
     84 
     85def srun_launcher(kdict={}): 
     86    """ 
     87prepare launch for parallel execution using srun 
     88syntax:  srun -n(nodes) (python) (file) (progargs) 
     89 
     90NOTES: 
     91 - run non-python commands with: {'python':'', ...}  
     92 - fine-grained resource utilization with: {'nodes':'4 -N1', ...} 
     93    """ 
     94    mydict = defaults.copy() 
     95    mydict.update(kdict) 
     96    str =  """ srun -n%(nodes)s %(python)s %(file)s %(progargs)s""" % mydict 
    5897    return str 
    5998 
     
    64103syntax:  echo \"mpirun -np (nodes) (python) (file) (progargs)\" | qsub -l nodes=(nodes) -l walltime=(timelimit) -o (outfile) -e (errfile) -q (queue) 
    65104 
    66 NOTE: run non-python commands with: {'python':'', ...}  
    67     """ 
    68     mydict = defaults.copy() 
    69     mydict.update(kdict) 
    70     mydict['tasks'] = tasks(mydict['nodes']) 
     105NOTES: 
     106 - run non-python commands with: {'python':'', ...}  
     107 - fine-grained resource utilization with: {'nodes':'4:nodetype:ppn=1', ...} 
     108    """ 
     109    mydict = defaults.copy() 
     110    mydict.update(kdict) 
     111    mydict['tasks'] = mpirun_tasks(mydict['nodes']) 
    71112    str = """ echo \"mpirun -np %(tasks)s %(python)s %(file)s %(progargs)s\" | qsub -l nodes=%(nodes)s -l walltime=%(timelimit)s -o %(outfile)s -e %(errfile)s -q %(queue)s &> %(jobfile)s""" % mydict 
     113    return str 
     114 
     115 
     116def moab_launcher(kdict={}): 
     117    """ 
     118prepare launch for moab submission using srun 
     119syntax:  echo \"srun -n(nodes) (python) (file) (progargs)\" | qsub -l nodes=(nodes) -l walltime=(timelimit) -o (outfile) -e (errfile) -q (queue) 
     120 
     121NOTES: 
     122 - run non-python commands with: {'python':'', ...}  
     123 - fine-grained resource utilization with: {'nodes':'4:ppn=1,partition=xx', ...} 
     124    """ 
     125    mydict = defaults.copy() 
     126    mydict.update(kdict) 
     127    mydict['tasks'] = srun_tasks(mydict['nodes']) 
     128    str = """ echo \"srun -n%(tasks)s %(python)s %(file)s %(progargs)s\" | msub -l nodes=%(nodes)s -l walltime=%(timelimit)s -o %(outfile)s -e %(errfile)s -q %(queue)s &> %(jobfile)s""" % mydict 
    72129    return str 
    73130 
     
    78135syntax:  bsub -K -W(timelimit) -n (nodes) -o (outfile) -a mpich_mx -q (queue) -J (progname) mpich_mx_wrapper (python) (file) (progargs) 
    79136 
    80 NOTE: run non-python commands with: {'python':'', ...}  
     137NOTES: 
     138 - run non-python commands with: {'python':'', ...}  
    81139    """ 
    82140    mydict = defaults.copy() 
     
    92150syntax:  bsub -K -W(timelimit) -n (nodes) -o (outfile) -a mpich_gm -q (queue) -J (progname) gmmpirun_wrapper (python) (file) (progargs) 
    93151 
    94 NOTE: run non-python commands with: {'python':'', ...}  
     152NOTES: 
     153 - run non-python commands with: {'python':'', ...}  
    95154    """ 
    96155    mydict = defaults.copy() 
Note: See TracChangeset for help on using the changeset viewer.