[cig-commits] r6689 - in cs/pythia/trunk: mpi pyre/applications
pyre/schedulers
leif at geodynamics.org
leif at geodynamics.org
Wed Apr 25 17:16:22 PDT 2007
Author: leif
Date: 2007-04-25 17:16:21 -0700 (Wed, 25 Apr 2007)
New Revision: 6689
Modified:
cs/pythia/trunk/mpi/Application.py
cs/pythia/trunk/mpi/Launcher.py
cs/pythia/trunk/mpi/__init__.py
cs/pythia/trunk/pyre/applications/Shell.py
cs/pythia/trunk/pyre/schedulers/Job.py
Log:
Added some handy built-in macros:
${job.name} : LSF/PBS job name specified using "job.name"
${nodes} : number of machine nodes
${rank} : result of MPI_Comm_rank(MPI_COMM_WORLD)
These are only expanded when the job is running (i.e., they are not
expanded on the head/login node). The ${rank} macro is only expanded
when running in parallel under 'mpirun'.
These built-in macros are the low-hanging fruit. There are more
built-in macros to come...
(Note that Launcher's specialized macro processor for
'launcher.command' has now been replaced by the general-purpose macro
facility.)
Modified: cs/pythia/trunk/mpi/Application.py
===================================================================
--- cs/pythia/trunk/mpi/Application.py 2007-04-26 00:11:50 UTC (rev 6688)
+++ cs/pythia/trunk/mpi/Application.py 2007-04-26 00:16:21 UTC (rev 6689)
@@ -42,12 +42,13 @@
requires = self.requires()
entry = self.entryName()
argv = self.getArgv(*args, **kwds)
+ state = self.getStateArgs() + self.job.getStateArgs()
# initialize the job
job = self.job
job.nodes = self.nodes
job.executable = self.jobExecutable
- job.arguments = ["--pyre-start", path, requires, "pyre.schedulers:jobstart", entry] + argv
+ job.arguments = ["--pyre-start", path, requires, "pyre.schedulers:jobstart", entry] + argv + state
# for debugging purposes, add 'mpirun' command as a comment
launcher = self.prepareLauncher()
@@ -66,12 +67,13 @@
requires = self.requires()
entry = self.entryName()
argv = self.getArgv(*args, **kwds)
+ state = self.getStateArgs() + self.job.getStateArgs()
# initialize the launcher
launcher = self.launcher
launcher.nodes = self.nodes
launcher.executable = self.mpiExecutable
- launcher.arguments = ["--pyre-start", path, requires, "mpi:mpistart", entry] + argv
+ launcher.arguments = ["--pyre-start", path, requires, "mpi:mpistart", entry] + argv + state
return launcher
@@ -85,10 +87,19 @@
return
+
def onComputeNodes(self, *args, **kwds):
self.main(*args, **kwds)
+ def getStateArgs(self):
+ state = []
+ state.append("--nodes=%d" % self.nodes) # in case it was computed
+ # define macros
+ state.append("--macros.nodes=%d" % self.nodes)
+ return state
+
+
def __init__(self, name=None):
super(Application, self).__init__(name)
Modified: cs/pythia/trunk/mpi/Launcher.py
===================================================================
--- cs/pythia/trunk/mpi/Launcher.py 2007-04-26 00:11:50 UTC (rev 6688)
+++ cs/pythia/trunk/mpi/Launcher.py 2007-04-26 00:16:21 UTC (rev 6689)
@@ -60,21 +60,11 @@
if self.nodes < 1:
self.nodes = 1
- # Build the 'mpirun' command. The macro-expansion feature is
- # to allow the user to express the full range of possible
- # 'mpirun' commands from a configuration file, while
- # hard-coding as little as possible here. On a workstation or
- # Beowulf, the default is usually correct, but on TACC's new
- # Lonestar system (for example), the proper command is simply
- # 'ibrun' (the number of nodes is not given).
-
- from pyre.util import expandMacros
- from os import environ
+ # Environment variable references such as ${PBS_NODEFILE} are
+ # allowed in 'command', thanks to the Preprocessor component.
+ # See mpi.Application.getStateArgs() to see how the ${nodes}
+ # macro is defined.
args = self.command.split(' ')
- substitutions = dict()
- substitutions.update(environ) # to allow, for example, ${PBS_NODEFILE}
- substitutions['nodes'] = '%d' % self.nodes
- args = [expandMacros(arg, substitutions) for arg in args]
# use only the specific nodes specified explicitly
if self.nodelist:
Modified: cs/pythia/trunk/mpi/__init__.py
===================================================================
--- cs/pythia/trunk/mpi/__init__.py 2007-04-26 00:11:50 UTC (rev 6688)
+++ cs/pythia/trunk/mpi/__init__.py 2007-04-26 00:16:21 UTC (rev 6689)
@@ -25,9 +25,16 @@
import sys
from pyre.applications import start, AppRunner
+ from mpi import MPI_Comm_rank, MPI_COMM_WORLD
+ rank = MPI_Comm_rank(MPI_COMM_WORLD)
+ macros = {
+ 'rank': str(rank),
+ }
+
kwds = kwds.get('kwds', dict())
kwds['message'] = 'onComputeNodes'
+ kwds['macros'] = macros
try:
start(argv,
Modified: cs/pythia/trunk/pyre/applications/Shell.py
===================================================================
--- cs/pythia/trunk/pyre/applications/Shell.py 2007-04-26 00:11:50 UTC (rev 6688)
+++ cs/pythia/trunk/pyre/applications/Shell.py 2007-04-26 00:16:21 UTC (rev 6689)
@@ -114,6 +114,7 @@
app.updateConfiguration(app.registry)
# enable macro expansion
+ self.pp.updateMacros(kwds.get('macros', {}))
context.pp = self.pp
# transfer user input to the app's inventory
Modified: cs/pythia/trunk/pyre/schedulers/Job.py
===================================================================
--- cs/pythia/trunk/pyre/schedulers/Job.py 2007-04-26 00:11:50 UTC (rev 6688)
+++ cs/pythia/trunk/pyre/schedulers/Job.py 2007-04-26 00:16:21 UTC (rev 6689)
@@ -47,4 +47,11 @@
self.nodes = 1
+ def getStateArgs(self):
+ state = []
+ # define macros
+ state.append("--macros.job.name=%s" % self.task)
+ return state
+
+
# end of file
More information about the cig-commits
mailing list