2013-10-12 08:28:27 +00:00
|
|
|
"""
|
|
|
|
Start mpi processes (and allow commands to be run inside process)
|
|
|
|
"""
|
2012-12-14 03:54:26 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from teuthology import misc as teuthology
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
def task(ctx, config):
|
|
|
|
"""
|
|
|
|
Setup MPI and execute commands
|
|
|
|
|
|
|
|
Example that starts an MPI process on specific clients::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- ceph-fuse: [client.0, client.1]
|
2013-01-08 15:56:41 +00:00
|
|
|
- ssh_keys:
|
2012-12-14 03:54:26 +00:00
|
|
|
- mpi:
|
|
|
|
nodes: [client.0, client.1]
|
|
|
|
exec: ior ...
|
|
|
|
|
|
|
|
Example that starts MPI processes on all clients::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- ceph-fuse:
|
2013-01-08 15:56:41 +00:00
|
|
|
- ssh_keys:
|
2012-12-14 03:54:26 +00:00
|
|
|
- mpi:
|
|
|
|
exec: ior ...
|
|
|
|
|
|
|
|
Example that starts MPI processes on all roles::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
2013-01-08 15:56:41 +00:00
|
|
|
- ssh_keys:
|
2012-12-14 03:54:26 +00:00
|
|
|
- mpi:
|
|
|
|
nodes: all
|
|
|
|
exec: ...
|
|
|
|
|
2013-01-08 15:56:41 +00:00
|
|
|
Example that specifies a working directory for MPI processes:
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- ceph-fuse:
|
|
|
|
- pexec:
|
|
|
|
clients:
|
2013-01-23 20:37:39 +00:00
|
|
|
- ln -s {testdir}/mnt.* {testdir}/gmnt
|
2013-01-08 15:56:41 +00:00
|
|
|
- ssh_keys:
|
|
|
|
- mpi:
|
|
|
|
exec: fsx-mpi
|
2013-01-23 20:37:39 +00:00
|
|
|
workdir: {testdir}/gmnt
|
2013-01-08 15:56:41 +00:00
|
|
|
- pexec:
|
|
|
|
clients:
|
2013-01-23 20:37:39 +00:00
|
|
|
- rm -f {testdir}/gmnt
|
2013-01-08 15:56:41 +00:00
|
|
|
|
2013-10-12 08:28:27 +00:00
|
|
|
:param ctx: Context
|
|
|
|
:param config: Configuration
|
2012-12-14 03:54:26 +00:00
|
|
|
"""
|
|
|
|
assert isinstance(config, dict), 'task mpi got invalid config'
|
|
|
|
assert 'exec' in config, 'task mpi got invalid config, missing exec'
|
2013-03-10 05:20:43 +00:00
|
|
|
|
|
|
|
testdir = teuthology.get_testdir(ctx)
|
|
|
|
|
|
|
|
mpiexec = config['exec'].replace('$TESTDIR', testdir)
|
2012-12-14 03:54:26 +00:00
|
|
|
hosts = []
|
|
|
|
remotes = []
|
|
|
|
master_remote = None
|
|
|
|
if 'nodes' in config:
|
|
|
|
if isinstance(config['nodes'], basestring) and config['nodes'] == 'all':
|
|
|
|
for role in teuthology.all_roles(ctx.cluster):
|
2014-03-27 16:35:28 +00:00
|
|
|
(remote,) = ctx.cluster.only(role).remotes.iterkeys()
|
2012-12-14 03:54:26 +00:00
|
|
|
ip,port = remote.ssh.get_transport().getpeername()
|
|
|
|
hosts.append(ip)
|
|
|
|
remotes.append(remote)
|
2014-03-27 16:35:28 +00:00
|
|
|
(master_remote,) = ctx.cluster.only(config['nodes'][0]).remotes.iterkeys()
|
2012-12-14 03:54:26 +00:00
|
|
|
elif isinstance(config['nodes'], list):
|
|
|
|
for role in config['nodes']:
|
2014-03-27 16:35:28 +00:00
|
|
|
(remote,) = ctx.cluster.only(role).remotes.iterkeys()
|
2012-12-14 03:54:26 +00:00
|
|
|
ip,port = remote.ssh.get_transport().getpeername()
|
|
|
|
hosts.append(ip)
|
|
|
|
remotes.append(remote)
|
2014-03-27 16:35:28 +00:00
|
|
|
(master_remote,) = ctx.cluster.only(config['nodes'][0]).remotes.iterkeys()
|
2012-12-14 03:54:26 +00:00
|
|
|
else:
|
|
|
|
roles = ['client.{id}'.format(id=id_) for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client')]
|
2014-03-27 16:35:28 +00:00
|
|
|
(master_remote,) = ctx.cluster.only(roles[0]).remotes.iterkeys()
|
2012-12-14 03:54:26 +00:00
|
|
|
for role in roles:
|
2014-03-27 16:35:28 +00:00
|
|
|
(remote,) = ctx.cluster.only(role).remotes.iterkeys()
|
2012-12-14 03:54:26 +00:00
|
|
|
ip,port = remote.ssh.get_transport().getpeername()
|
|
|
|
hosts.append(ip)
|
|
|
|
remotes.append(remote)
|
|
|
|
|
2013-01-08 15:56:41 +00:00
|
|
|
workdir = []
|
|
|
|
if 'workdir' in config:
|
2013-03-10 05:20:43 +00:00
|
|
|
workdir = ['-wdir', config['workdir'].replace('$TESTDIR', testdir) ]
|
2013-01-08 15:56:41 +00:00
|
|
|
|
2012-12-14 03:54:26 +00:00
|
|
|
log.info('mpi rank 0 is: {name}'.format(name=master_remote.name))
|
|
|
|
|
|
|
|
# write out the mpi hosts file
|
|
|
|
log.info('mpi nodes: [%s]' % (', '.join(hosts)))
|
2013-01-23 20:37:39 +00:00
|
|
|
teuthology.write_file(remote=master_remote,
|
|
|
|
path='{tdir}/mpi-hosts'.format(tdir=testdir),
|
|
|
|
data='\n'.join(hosts))
|
2012-12-14 03:54:26 +00:00
|
|
|
log.info('mpiexec on {name}: {cmd}'.format(name=master_remote.name, cmd=mpiexec))
|
2013-01-23 20:37:39 +00:00
|
|
|
args=['mpiexec', '-f', '{tdir}/mpi-hosts'.format(tdir=testdir)]
|
2013-01-08 15:56:41 +00:00
|
|
|
args.extend(workdir)
|
2012-12-14 03:54:26 +00:00
|
|
|
args.extend(mpiexec.split(' '))
|
|
|
|
master_remote.run(args=args, )
|
|
|
|
log.info('mpi task completed')
|
2013-01-23 20:37:39 +00:00
|
|
|
master_remote.run(args=['rm', '{tdir}/mpi-hosts'.format(tdir=testdir)])
|