How I can create a hostfile using MPI?

r mpi
14,162

The name of the nodes has to be either their IP address or their DNS hostname. You can get the name of the node, if you know the IP address, by querying the DNS server (depends on your system: Windows, Linux, etc.).

Example:

localhost
192.168.1.2
host01.clusterdomain

I suggest you to check if the system you are working with uses any kind of job scheduler. If it does, you won't need to care about specifying the hostfile, as the job scheduler will take care of that (you just specify the amount of resource -i.e. nodes- that you want).

Finally, the hostfile is only necessary in the host where you are executing the process manager (mpirun, mpiexec, etc.). Using a shared filesystem, however, will ensure all the files needed by your application, including the hostfile (in case you needed it) will be available at every node of the cluster.

Share:
14,162
olegario
Author by

olegario

Updated on June 04, 2022

Comments

  • olegario
    olegario almost 2 years

    I need to run a MPI application on 8 nodes, with 16 CPUs each. Even after some research, I still don't understand how hostfiles work. I'm using R with the doMPI and Rmpi libraries.

    This is what I understood so far:

    I have a hostfile my-hosts that looks like:

    node1 slots=16
    node2 slots=16
    .
    .
    .
    

    Can I simply call the nodes by nodeX?

    How can I get the name of the node?

    Is there any function such as getNodeName()?

    Is the following command line enough to launch the application?

    mpirun -np 1 -host my_host ....
    

    Is it necessary to have the hostfile on all nodes?