Package starcluster :: Package plugins :: Module mpich2
[hide private]
[frames] | no frames]

Source Code for Module starcluster.plugins.mpich2

 1  from starcluster.clustersetup import DefaultClusterSetup 
 2  from starcluster.logger import log 
 3   
 4   
5 -class MPICH2Setup(DefaultClusterSetup):
6 7 MPICH2_HOSTS = '/etc/mpich2.hosts' 8 MPICH2_PROFILE = '/etc/profile.d/mpich2.sh' 9
10 - def _configure_hosts_file(self, node, aliases):
11 mpich2_hosts = node.ssh.remote_file(self.MPICH2_HOSTS, 'w') 12 mpich2_hosts.write('\n'.join(aliases)) 13 mpich2_hosts.close() 14 mpich2_profile = node.ssh.remote_file(self.MPICH2_PROFILE, 'w') 15 mpich2_profile.write("export HYDRA_HOST_FILE=%s" % self.MPICH2_HOSTS)
16
17 - def _update_alternatives(self, node):
18 mpi_choices = node.ssh.execute("update-alternatives --list mpi") 19 mpirun_choices = node.ssh.execute("update-alternatives --list mpirun") 20 mpipath = None 21 for choice in mpi_choices: 22 if 'mpich2' in choice: 23 mpipath = choice 24 break 25 mpirunpath = None 26 for choice in mpirun_choices: 27 if 'mpich2' in choice: 28 mpirunpath = choice 29 break 30 node.ssh.execute("update-alternatives --set mpi %s" % mpipath) 31 node.ssh.execute("update-alternatives --set mpirun %s" % mpirunpath)
32
33 - def run(self, nodes, master, user, shell, volumes):
34 aliases = map(lambda x: x.alias, nodes) 35 log.info("Setting up MPICH2 hosts file on all nodes") 36 for node in nodes: 37 self.pool.simple_job(self._configure_hosts_file, 38 (node, aliases), 39 jobid=node.alias) 40 self.pool.wait(len(nodes)) 41 log.info("Setting MPICH2 as default MPI on all nodes") 42 for node in nodes: 43 self.pool.simple_job(self._update_alternatives, (node), 44 jobid=node.alias) 45 self.pool.wait(len(nodes)) 46 log.info("MPICH2 is now ready to use") 47 log.info( 48 "Use mpicc, mpif90, mpirun, etc. to compile and run your MPI apps")
49